All docs This doc
Skip to end of metadata
Go to start of metadata

A JMS synchronous invocation takes place when a JMS producer receives a response to a JMS request produced by it when invoked. WSO2 ESB uses an internal JMS correlation ID to correlate the request and the response. See JMS Request/Reply Example for more information.

JMS synchronous invocations are further explained in the following use case.

Use case   

When the proxy service named SMSSenderProxy receives an HTTP request, it publishes that request in a JMS queue named SMSStore. Another proxy service named SMSForwardProxy subscribes to messages published in this queue and forwards them to a back-end service named SimpleStockQuoteService. When this back-end service returns an HTTP response, internal ESB logic is used to save that message as a JMS message in a JMS queue named SMSReceiveNotification. Then this response is taken from the SMSReceiveNotification queue and delivered to the client as an HTTP message using internal ESB logic.

The following sub sections explain how to execute this use case. WSO2 Message Broker is used as the JMS broker.


Before executing this use case, the following steps need to be carried out. See Integrating WSO2 ESB in MB Documentation for detailed instructions.

  • WSO2 MB should be installed and set up. See Setting up WSO2 Message Broker.
  • WSO2 ESB should installed and set up. See Setting up WSO2 ESB. Specific entries that are required to be added to the <ESB_HOME>/repository/conf/ file for this use case are as follows.



    Connection Factory
    connectionfactory.QueueConnectionFactory = amqp://admin:[email protected]/carbon?brokerlist='tcp://localhost:5673'

Configuring the JMS publisher

Configure a proxy service named SMSSenderProxy as shown below to accept messages sent via the HTTP transport, and to place those messages in the SMSStore queue in WSO2 MB.

Example code 4
<proxy xmlns=""
         <property name="transport.jms.ContentTypeProperty"
         <property name="TRANSPORT_HEADERS" scope="axis2" action="remove"/>
         <address uri="jms:/SMSStore?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&amp;java.naming.provider.url=repository/conf/;transport.jms.DestinationType=queue&amp;transport.jms.ReplyDestination=SMSReceiveNotificationStore"/>

The endpoint of this proxy service uses the following properties to map the proxy service with WSO2 MB.

PropertyValue for this use caseDescription

address uri


The destination in which the request received by the proxy service is stored.



This property specifies the initial context factory to use. The value specified here should be the same as that specified in <ESB_HOME>/repository/conf/axis2/axis2.xml for the JMS transport receiver.



The location of the JNDI service provider.


queueThe destination type of the JMS message that will be generated by the proxy service.


The destination in which the response generated by the back-end service is stored.

Since this is a two-way invocation, the OUT_ONLY property is not set in the In sequence. 

Configuring the JMS consumer

Configure a proxy service named SMSForwardProxy to consume messages from the SMSStore queue in WSO2 MB and forward them to the back-end service.

<proxy xmlns=""
               <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
   <parameter name="transport.jms.ContentType">
   <parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
   <parameter name="transport.jms.DestinationType">queue</parameter>
   <parameter name="transport.jms.Destination">SMSStore</parameter>

The transport.jms.ConnectionFactory, transport.jms.DestinationType and transport.jms.Destination properties map this proxy service to the SMSStore queue.

The SimpleStockQuoteService sample shipped with WSO2 ESB is used as the back-end service in this example. To invoke this service, the address URI of this proxy service is defined as  http://localhost:9000/services/SimpleStockQuoteService.

Start the back-end service

In this example, the SimpleStockQuoteService serving as the back-end receives the message from the SMSForwardProxy proxy service via the JMS transport. The response is sent by SimpleStockQuoteService is published in the SMSReceiveNotificationStore queue which was set as the value for the transport.jms.ReplyDestination parameter of the SMSSenderProxy proxy service. This allows the SMSSenderProxy to pick the response and deliver it to the client.

The back-end service is started as follows.

  1. Execute the following command from the <ESB_HOME>/samples/axis2Server directory.
    For Windows: axis2server.bat
    For Linux:
  2. Execute the ant command from <ESB_HOME>/samples/axis2Server/src/SimpleStockQuoteService directory.

Invoke the JMS publisher

Execute the following command from the <ESB_HOME>/sample/axis2Client directory to invoke the SMSSenderProxy proxy service you defined as the JMS publisher.

ant stockquote -Daddurl=http://localhost:8280/services/SMSSenderProxy -Dsymbol=IBM

You will get the following response.

Standard :: Stock price = $149.43669233447662
  • No labels