@maksim_makh

Паттерн обмена сообщениями (чат) между клиентами в реальном времени?

Ищу пример, паттерн обмена текстовыми сообщениями между моб. клиентами (на примере месседжера Whatsup.. etc)
В распоряжении JAVA, JS, STOMP over SockJs, NoSQL, RabbitMQ.

Планирую хранить сообщения в бд, передавать по STOMP. Хотелось бы почитать материал по теме. Спасибо за любую инфу.

Обновление

Вот что нашел на данный момент,
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 seee his old conversations.
The pros of 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 above implementations, and I'm wondering if there's any easier way to achieve this?
  • Вопрос задан
  • 776 просмотров
Пригласить эксперта
Ответы на вопрос 2
aratj
@aratj
программер.
веб сокеты, например.
но вообще почитать про XMPP
а еще , лучше, не городить велосипед, по погуглить готовые решения
типа openfire
Ответ написан
Комментировать
@gbir
IOS Developer
Eсть полезная библиотека, signalr позволяет организовать чат достаточно быстро, она дает возможность работать с сокетами и long polling.

https://github.com/DyKnow/SignalR-ObjC
https://github.com/SignalR/java-client
www.asp.net/signalr

пример чата:
www.asp.net/signalr/overview/getting-started/tutor...
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы