[rabbitmq-discuss] New Plugin: External Exchange

Matthew Sackman matthew at lshift.net
Tue Apr 6 11:57:57 BST 2010


RabbitMQ External Exchange Plugin
=================================

http://hg.rabbitmq.com/rabbitmq-external-exchange
http://hg.rabbitmq.com/rabbitmq-external-exchange/file/default/README


Overview
--------

This plugin allows you to write implementations of exchange types as
normal AMQP clients of RabbitMQ using any of the multitude of AMQP
clients available.

Example frameworks for both Java (using the RabbitMQ Java client) and
Erlang (using the RabbitMQ Erlang client) are provided to demonstrate
the cleanliness of API that can be achieved.


Introduction
------------

AMQP provides 4 basic exchange types: "fanout", "direct", "topic" and
"headers". It also provides a means to allow custom exchange types to
be used, requiring that any such custom exchange types start with a
"x-" prefix.

RabbitMQ provides pluggable exchange types, which permit new exchange
types to be provided by filling in a thin API. This API allows the
custom exchange type to be notified of exchange creation, deletion,
the addition and removal of bindings, and the publishing messages to
an exchange. The custom exchange may, upon being told of a publish,
modify the message or any of its meta-data, and route it to any queue.

However, the custom exchange is called directly by each channel, and
so does not serialise events, making it a little challenging (though
by no means overly tricky) to maintain state. It also requires the
exchange to be written in Erlang and to run directly in the same
Erlang VM as RabbitMQ (though note that plugins such as the
script-exchange allow for functions written in scripting languages
such as Javascript to be run on every publish).

This plugin takes the events relating to exchanges, encapsulates them
in AMQP and performs RPC to an external client. This allows further
choice of language, flexibility of implementation, and permits all
events to be processed by a single thread, thus making it easier for
the exchange type implementation to be stateful (though it's by no
means impossible to achieve a stateful exchange without this plugin).

See the README linked above for the rest of the details including the
APIs of the example frameworks.

Matthew




More information about the rabbitmq-discuss mailing list