M
M
maksim_makh2016-02-03 13:30:03
Web development
maksim_makh, 2016-02-03 13:30:03

A pattern of messaging (chat) between clients in real time?

I'm looking for an example, a pattern of text messaging between mobs. clients (using the Whatsup..etc messenger as an example)
JAVA, JS, STOMP over SockJs, NoSQL, RabbitMQ are available.
I am going to store messages in a DB, to transfer on STOMP. I would like to read material on the topic. Thanks for any info.
Update
Here's what I've found so far,
stackoverflow.com/questions/32541910/sending-messa...

1) Send message from the client which is received by the socket server which then sends it to the receiving client. On the background I store that to the message on the DB to be retrieved later if the user wishes to see his old conversations.
The prosof this approach is that the user gets the message almost instantly since we don't wait for the DB operation to complete, but the con is that if the DB operation failed and exactly that time the client refreshed its page to fetch the message, it won't get that.
2) Send message form the client to the server, the server then stores it on the DB first and then only sends it to the receiving client.
The pros is that we make sure that the message will be received to the client only if its stored in the DB. The con is that it will be no way close to real time since we'll be doing a DB operation in between slowing down the message passing.
3)Send message to the client which then is stored on a cache layer(redis for example) and then instantly broadcast it to the receiving client. On background keep fetching records from redis and updating DB. If the client refreshes the page, we first look into the DB and then the redis layer.
The pros is that we make the communication faster and also make sure messages are presented correctly on demand. The con is that this is quite complex as compared to the above implementations, and I'm wondering if there's any easier way to achieve this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Marat S, 2016-02-03
@aratj

web sockets, for example.
but in general to read about XMPP
and even better not to fence the bike, to google ready-made solutions
like openfire

M
Maxim, 2016-02-05
@gbir

There is a useful library, signalr allows you to organize a chat quite quickly, it makes it possible to work with sockets and long polling.
https://github.com/DyKnow/SignalR-ObjC
https://github.com/SignalR/java-client
www.asp.net/signalr
chat example:
www.asp.net/signalr/overview/getting-started/ tutor...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question