Using the JDBC Message Store

In this sample, the client sends requests to a proxy service. The proxy service stores the messages in a JDBC message store. The back-end service is invoked by a message forwarding processor, which picks the messages stored in the JDBC message store.


Setup the database. Use one of the following DB scripts depending on which database type you want to use.

CREATE TABLE jdbc_message_store(
            indexId BIGINT( 20 ) NOT NULL AUTO_INCREMENT ,
            msg_id VARCHAR( 200 ) NOT NULL ,
            message BLOB NOT NULL ,
            PRIMARY KEY ( indexId )
CREATE TABLE jdbc_message_store(
                indexId BIGINT( 20 ) NOT NULL AUTO_INCREMENT ,
                msg_id VARCHAR( 200 ) NOT NULL ,
                message BLOB NOT NULL ,
                PRIMARY KEY ( indexId )


You can create a similar script based on the database you want to set up.

Add the relevant database driver into the <MI_HOME>/lib directory.

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.

This sample configuration uses a MySQL database named sampleDB and the database table named jdbc_message_store.

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="MessageStoreProxy" startOnLoad="true" transports="http https" xmlns="">
          <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
          <property name="OUT_ONLY" value="true"/>
          <property name="target.endpoint" value="StockQuoteServiceEp"/>
          <store messageStore="SampleStore"/>
    <publishWSDL uri="file:/path/to/sample_proxy_1.wsdl"/>
<?xml version="1.0" encoding="UTF-8"?>
<messageStore class="" name="SampleStore" xmlns="">
    <parameter name="store.jdbc.driver">com.mysql.jdbc.Driver</parameter>
    <parameter name="">false</parameter>
    <parameter name="store.jdbc.username">root</parameter>
    <parameter name="store.jdbc.connection.url">jdbc:mysql://localhost:3306/sampleDB</parameter>
    <parameter name="store.jdbc.password">********</parameter>
    <parameter name="store.jdbc.table">jdbc_message_store</parameter>
<?xml version="1.0" encoding="UTF-8"?>
<messageProcessor class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" messageStore="SampleStore" name="ScheduledProcessor" targetEndpoint="StockQuoteServiceEp" xmlns="">
    <parameter name="client.retry.interval">1000</parameter>
    <parameter name="">5</parameter>
    <parameter name="member.count">1</parameter>
    <parameter name="store.connection.retry.interval">1000</parameter>
    <parameter name="">-1</parameter>
    <parameter name="">Disabled</parameter>
    <parameter name="interval">10000</parameter>
    <parameter name="">true</parameter>
<endpoint xmlns="" name="StockQuoteServiceEp">
  <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>

Build and run

The WSDL file sample_proxy_1.wsdl can be downloaded from sample_proxy_1.wsdl. The WSDL URI needs to be updated with the path to the sample_proxy_1.wsdl file.

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, message processor, and endpoint 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:


Send the following request to invoke the sample proxy service:

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