Skip to content

Using the RabbitMQ Message Store

In this example, the client sends requests to a proxy service, which stores the messages in a RabbitMQ message store. The message forwarding processor then picks the stored messages from the RabbitMQ message store and invokes the back-end service.

Synapse configurations

Following are the artifact configurations that we can use to implement this scenario. See the instructions on how to build and run this example.

<?xml version="1.0" encoding="UTF-8"?>
<messageStore class="" name="rabbitmq" xmlns="">
    <parameter name="">localhost</parameter>
    <parameter name="">false</parameter>
    <parameter name="">5672</parameter>
    <parameter name="store.rabbitmq.route.key"/>
    <parameter name="store.rabbitmq.username"/>
    <parameter name=""/>
    <parameter name="rabbitmq.connection.ssl.enabled">false</parameter>
    <parameter name=""/>
    <parameter name="">xyz</parameter>
    <parameter name="store.rabbitmq.password"/>
<endpoint xmlns="" name="SimpleStockQuoteService"> 
    <address uri=""/>
<proxy xmlns="" name="Proxy1" transports="https http" startOnLoad="true" trace="disable">   
      <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
      <property name="OUT_ONLY" value="true"/>
      <log level="full"/>
      <store messageStore="rabbitmq"/>
<messageProcessor xmlns="" class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" name="Processor1" targetEndpoint="SimpleStockQuoteService" messageStore="rabbitmq">
       <parameter name="">4</parameter>
       <parameter name="interval">4000</parameter>
       <parameter name="">true</parameter>

See the descriptions of the above configurations:

Artifact Description
Message Store The RabbitMQ message store.
Endpoint Define an endpoint which is used to send the message to the back-end service.
Proxy Service Create a proxy service which stores messages to the created Message Store. Note that you can use the FORCE_SC_ACCEPTED property in the message flow to send an Http 202 status to the client after the Micro Integrator accepts a message. If this property is not specified, the client that sends the request to the proxy service will timeout since it isbnot getting any response back from the proxy.
Message Processor Create a message forwarding processor using the below configuration. Message forwarding processor consumes the messages stored in the message store.

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 the proxy service, endpoint, and message processor with the configurations given above.
  4. Deploy the artifacts in your Micro Integrator.

Set up the back-end service:

  1. Download the back-end service.
  2. Extract the downloaded zip file.
  3. Open a terminal, navigate to the axis2Server/bin/ directory inside the extracted folder.
  4. Execute the following command to start the axis2server with the SimpleStockQuote back-end service:


Configure the RabbitMQ broker with the Micro Integrator.

Invoke the service:

POST http://localhost:9090/services/Proxy1 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:getQuote"
Content-Length: 492
Host: localhost:9090
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope xmlns:soapenv="" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
      <ser:getQuote xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">

Note a message similar to the following example:

SimpleStockQuoteService :: Accepted order for : 7482 stocks of IBM at $ 169.27205579038733