Skip to content

Introduction to Message Stores

This sample demonstrates the basic functionality of a message store.

Synapse configuration

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

<proxy xmlns="" name="SampleProxy" transports="http" startOnLoad="true" trace="disable">
            <log level="full"/>
            <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
            <store messageStore="MyStore" sequence="onStoreSequence"/>
            <sequence key="OnError"/>
<sequence xmlns="" name="onStoreSequence">
        <property name="On-Store" value="Storing message"/>
<messageStore xmlns="" name="MyStore" />
<sequence xmlns="" name="OnError">
    <log level="full">
        <property name="MESSAGE" value="Executing default 'fault' sequence"/>
        <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
        <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>

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, message store, and mediation sequences with the configurations given above.
  4. Deploy the artifacts in your Micro Integrator.

Send the following request to invoke the service:

POST http://localhost:9090/services/SampleProxy 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">

In the proxy service, the store mediator will store the getQuote request message in the MyStore message store. Before storing the request, the message store mediator will invoke the onStoreSequence sequence.

Analyze the logs and you will see the following log:

INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /services/SampleProxy, WSAction: urn:getQuote, SOAPAction: urn:getQuote, MessageID: urn:uuid:ab78ee5d-f5ed-4346-a0ea-1beb2e6c0b1d, Direction: request, On-Store = Storing message

You can then use the JMX view of the Synapse message store using jconsole.