Skip to content

Using the RabbitMQ Inbound Endpoint

This sample demonstrates how one way message bridging from RabbitMQ to HTTP can be done using the inbound RabbitMQ endpoint.

Synapse configuration

Following are the integration artifacts that we can used to implement this scenario. See the instructions on how to build and run this example.

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="TestIn" trace="disable" xmlns="">
    <log level="full"/>
<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint name="test" onError="fault" protocol="rabbitmq" sequence="TestIn" suspend="false" xmlns="">
        <parameter name="sequential">true</parameter>
        <parameter name="coordination">true</parameter>
        <parameter name="rabbitmq.connection.factory">AMQPConnectionFactory</parameter>
        <parameter name="">localhost</parameter>
        <parameter name="rabbitmq.server.port">5672</parameter>
        <parameter name="">guest</parameter>
        <parameter name="rabbitmq.server.password">guest</parameter>
        <parameter name="">queue</parameter>
        <parameter name="">exchange</parameter>

Build and run

Create the artifacts:

  1. Set up WSO2 Integration Studio.
  2. Create an integration project with an ESB Configs module and an Composite Exporter.
  3. Create a mediation sequence and inbound endpoint with configurations given in the above example.
  4. Deploy the artifacts in your Micro Integrator.

Configure the RabbitMQ broker.

Use the following Java client to publish a request to the RabbitMQ broker.

ConnectionFactory factory = new ConnectionFactory();
Channel channel = null;
Connection connection = factory.newConnection();
channel = connection.createChannel();
channel.queueDeclare("queue", false, false, false, null);
channel.exchangeDeclare("exchange", "direct", true);
channel.queueBind("queue", "exchange", "route");

// The message to be sent
String message = "<m:placeOrder xmlns:m=\"http://services.samples\">" +
                "<m:order>" +
                "<m:price>100</m:price>" +
                "<m:quantity>20</m:quantity>" +
                "<m:symbol>RMQ</m:symbol>" +
                "</m:order>" +

// Populate the AMQP message properties
AMQP.BasicProperties.Builder builder = new AMQP.BasicProperties().builder();

// Publish the message to exchange
channel.basicPublish("exchange", "queue",, message.getBytes());

You will see the following Message content:

<soapenv:Envelope xmlns:soapenv=""><soapenv:Body><m:placeOrder xmlns:m="http://services.samples"><m:order><m:price>100</m:price><m:quantity>20</m:quantity><m:symbol>RMQ</m:symbol></m:order></m:placeOrder></soapenv:Body></soapenv:Envelope>

The RabbitMQ inbound endpoint gets the messages from the RabbitMQ broker and logs the messages in the Micro Integrator.