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.
This will be used as an example for the book RabbitMQ in Action.
The Recent History Exchange has to be installed prior to running this application.
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:
$ make
-
Install the Recent History Exchange plugin if you haven't done so.
-
Start RabbitMQ if is not running already.
Edit the file ./priv/chat_dev.config
to suit your RabbitMQ configuraion.
Start the server:
$ ./start-dev.sh
Point your browser to http://localhost:8080/. Invite your friends. Enjoy!
Create a file called ./priv/chat.config
with the proper values to suit your RabbitMQ configuraion.
See the file ./priv/chat_dev.config
for an example of the configuraion format.
Start the server:
$ ./start.sh
Inspired by YakRiak
Original design adapted from YakRiak. Thanks Basho and the crew, specially @pharkmillups for being an awesome community manager.
See LICENSE.md