Skip to main content


Showing posts from August, 2017

Receiving Fanout Messages on SockJS Subscribers in RabbitMQ

SockJS is a popular library for receiving and sending messages from messaging queues in Javascript which works on Stomp over Websockets. The basic underlying architecture of RabbitMQ consists of Exchanges which receive messages and distribute them to respective queues. One message in general is received by one consumer. Sometimes there is a need to send (or broadcast) messages to multiple consumers. In this case, the Publish/Subscribe mechanism of RabbitMQ can be utilized.

This tutorial focuses on creating a RabbitMQ publisher in Python using the Pika library and consuming the messages in a SockJS client. Since this we will be consuming messages directly from the Exchange, any number of consumers can be created and they will all receive the messages.

Creating a Publisher in Python The following code creates a connection to RabbitMQ server on localhost, creates a new exchange named 'broadcast' and publishes a message 'Hello World!' to it.

#!/usr/bin/env python
import pik…