Erlang's message queue model (Comet chat)?

I am doing Comet chat with Erlang. I use only one connection (long polling) to transport messages. But, as you know, a long-term connection cannot stay in touch all the time. Each time a new message arrives or reaches a timeout, it is interrupted and then reconnected to the server. If the message was sent before reconnecting, it is a problem of maintaining the integrity of the chat.

In addition, if a user opens more than one window with Comet-chat, all chat messages must be synchronized, which means that the user can have many long requests. Therefore, it is difficult to transmit all messages in a timely manner.

Should I create a message queue for each connection? Or what is the best way to solve this problem?

+4
source share
1 answer

For me, the easiest way to have one process / message queue for each user connected to the chat (even to have more than one chat window). Then keep track of the timestamp of the last message in the chat application, and when reconnecting, request messages after this timestamp. The message queue process should only store messages for a reasonable amount of time. In this case, reconnecting is up to the client. In another scenario, you can send some hart hits from the server, but it seems less reliable to me. This is not a solution to the problem with a different reason for the shutdown than timeout. There are many options for queuing on the server side as one queue for each client, for each user, for each chat, for ...

+1
source

All Articles