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; and, you can use RabbitMQ as a gateway from 0MQ to other protocols such as AMQP, STOMP or XMPP.


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 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:

          [{bind, "tcp://"}],
          [{bind, "tcp://"}],
          [{exchange, <<"amq.fanout">>}]},
          [{bind, "tcp://"}],
          [{bind, "tcp://"}],
          [{exchange, <<"pipeline">>}, {queue, <<"pipeline">>}]},
          [{bind, "tcp://"}],
          [{bind, "tcp://"}],
          [{req_queue, <<"requests">>}]}]}]}].

The general pattern for the r0mq section is

          [{BindOrConnect, InAddress}, ...],
          [{BindOrConnect, OutAddress}, ...],
          [{OptionKey, OptionValue}, ...]},


    ServiceType = pubsub
                | pipeline
                | reqrep
    BindOrConnect = bind
                  | connect

0MQ plugin for RabbitMQ maps different messaging patterns — as defined by 0MQ — to different encodings in the AMQP model. To understand exact semantics of each pattern, details of corresponding AMQP encoding and exact semantics of the associated configuration entries, check the pages dedicated to individual patterns:


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.