Skip to content


Subversion checkout URL

You can clone with
Download ZIP


sustrik edited this page · 31 revisions
Clone this wiki locally

0MQ plugin for RabbitMQ

The purpose of this plugin is to provision 0MQ sockets that relay messages into RabbitMQ. Each 0MQ socket type is given an idiomatic encoding in the AMQP broker model, which means AMQP clients can interoperate.

Among other things, this means you can use RabbitMQ as a device in a 0MQ network, gaining rabbity goodness such as persistence and monitoring. You can use RabbitMQ as a gateway from 0MQ to other protocols such as AMQP, STOMP or XMPP. You can also use 0MQ to access your RabbitMQ server from languages/platforms where there are no AMQP clients available.


You have to have both RabbitMQ server, 0MQ and Erlang binding for 0MQ installed.

For instructions concerning download and installation of RabbitMQ Server look here:

For instructions concerning download and installation of 0MQ look here:

For instructions concerning download and installation of Erlang binding for 0MQ look here:

Installation of r0mq plugin

Copy the files from the downloads section of this repository into the RabbitMQ plugin directory as explained here:


The mapping between 0MQ sockets and RabbitMQ exchanges and queues is managed by configuration. Each instance of a mapping is called a “service”.

The configuation file should be located in RabbitMQ configuration directory as explained here:

Here is an example, given as a complete RabbitMQ config file:

        [{"PIPELINE", push, "tcp://"},
         {"PIPELINE", pull, "tcp://"}]}]}]

Each service entry in the configuration is a triple consisting of a “rendez-vous point”, specification of what type of 0MQ sockets are going to connect to that rendez-vous point and the 0MQ-style address to bind the rendez-vous point to.

Rendez-vous point corresponds either to AMQP exchange or AMQP queue, depending on the messaging pattern. For req/rep pattern it’s the name of the request queue. For pub/sub pattern it’s the name of the exchange that serves as an entry point for the published messages. For pipeline (push/pull) pattern it corresponds to the shared queue to pass messages through.

For detailed diagrams of AMQP wiring corresponding to individual messaging patterns have a look at dedicated pages:

It’s not common for a broker to connect to another node on the network, however, it may come handy in federation scenarios. In such cases 0MQ address in the triple can be replaced by a pair consisting of bind or connect keyword and the 0MQ-style address:

        [{"PIPELINE", pull, {connect, "tcp://"}}]}]}]


Subdirectory examples contains some simple examples you can use to get familiar with r0mq.

Individual examples are written in Python so you have to install Python binding for 0MQ to be able to run them:

Each example contains a plugin configuration file (“rabbitmq.config”) you have to copy to RabbitMQ configuration directory as explained here:

The examples are:

  1. reqrep: is the service. It gets “Hello!” messages from the clients and responds with “World!” message. is the client, that sends the “Hello!” message and wait for the reply. It prints the reply and terminates. You can run as many services and clients in parallel as you wish.
  2. pipeline: This example shows how RabbitMQ broker can be used to gather messages from one processing step in the pipeline and forward them to the next step of the pipeline. If the next step is not keeping up with the rate of messages produced by the previous step, RabbitMQ server will queue the messages in the meantime. represents the previous step in the pipeline. It pushes one “Work!” message per second the the broker. represents the next processing step. It reads messages from the broker and prints them out. You can run as many pushers and pullers in parallel as you wish. The messages are load-balanced between individual pullers.
  3. pubsub: is the publisher. It sends an alternating sequence of “Hello?” and “World???” messages, one per second. is the subscriber. It subscribes for the messages starting witgh “W”, so it’s only get the “World???” messages. It prints them out. You can run as many publishers and subscribers in parallel as you wish.

Building the plugin from source

The make file fetches and builds 0MQ Erlang binding (erlzmq) for you. It assumes that libzmq has been put in /usr/local; change ZMQ_PATH in deps/erlzmq/Makefile if you put it somewhere else.

At the minute RabbitMQ plugins expect to be built from a directory in rabbitmq-public-umbrella, and this one is no exception. For detailed instructions on the process have a look here:

To build the plugin do the following:

    cd rmq-0mq

The resulting Erlang archives will be located in dist subdirectory.

Something went wrong with that request. Please try again.