This project shows how to create a simple web chat room with RabbitMQ.
The chat server uses Websockets to send messages to the connected users. This means it only works with Chrome and Safari. Some browsers like Firefox 4 can be configured to enable Websockets.
On the RabbitMQ side there it uses a custom exchange to store the last 20 messages, so new users connecting to the chat room can get a context of what's going on. See the project Recent History Exchange for installation instructions.
The Recent History Exchange has to be installed prior to running this application.
How does it work
Each user that connects to the server will get a private auto delete anonymous queue. This queue will be managed by an AMQP consumer. Whenever the AMQP consumer recieves a message it will forward it to the Websockets process and this one will send it to the user browser.
When the user is disconnects from the server his consumer gets closed and the queue deleted.
Get the source code:
$ git clone git://github.com/videlalvaro/rabbitmq-chat.git $ cd rabbitmq-chat
Compile the source code:
Install the Recent History Exchange plugin if you haven't done so.
Start RabbitMQ if is not running already.
Start the server:
Point your browser to http://localhost:8080/. Invite your friends. Enjoy!
Inspired by YakRiak