Real-time chat, don't want to lose messages - use queue (redis, zeromq)?

I have an application where there's some real-time chat. The chat is implemented using Faye on client side and server side (nodejs).

Now this client side chat is used in a rails applications and when my page reloads/refreshes I don't want to lose the messages which could happen in following scenario:

  • I reload the page
  • I get the chat records from the DB
  • User on the other side of the chat writes 5 lines
  • I render the page
  • I'm missing 5 recent records

I want to hear your opinions on solving this problem. I had something like a message queue in mind where messages not delivered to client would just wait in there and be fetched later when the page is up via javascript.

I also want your opinions if somebody confirms that message queue is a good fit on using zeromq or implementing simple queue in redis which I am using already (don't want to many technologies).

Redis has an impressive selection of queue features, pub/sub systems etc. ZeroMQ on the other side is more like an IPC layer for distributed applications, you would have to implement any high-level abstraction over it. It's like comparing HTTP and TCP.