Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

...

When the proxy service named SMSSenderProxy receives an HTTP request, it publishes that request in a JMS queue in a JMS broker 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 queue in the message broker. Then this response is taken from the SMSReceiveNotification  queue queue and delivered to the client as an HTTP message using internal ESB logic.

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

Table of Contents
maxLevel4
minLevel4

...

  • 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/jndi.properties file for this use case are as follows.

    ItemValue
    Queue
    queue.SMSStore=SMSStore
    Queue

    queue.SMSReceiveNotificationStore=SMSReceiveNotificationStore

    Connection Factory
    connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5673'

     

Configuring the JMS publisher

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

Code Block
languagexml
titleExample code 4
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SMSSenderProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="transport.jms.ContentTypeProperty"
                   value="Content-Type"
                   scope="axis2"/>
      </inSequence>
      <outSequence>
         <property name="TRANSPORT_HEADERS" scope="axis2" action="remove"/>
         <send/>
      </outSequence>
      <endpoint>
         <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/jndi.properties&amp;transport.jms.DestinationType=queue&amp;transport.jms.ReplyDestination=SMSReceiveNotificationStore"/>
      </endpoint>
   </target>
   <description/>
</proxy>

The endpoint of this proxy service uses the following properties to map the proxy service with WSO2 MB which serves as the JMS broker.

PropertyValue for this use caseDescription

address uri

jms:/SMSStore

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

java.naming.factory.initial

org.wso2.andes.jndi.PropertiesFileInitialContextFactory

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.

java.naming.provider.url

repository/conf/jndi.properties

The location of the JNDI service provider.

transport.jms.DestinationType

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

SMSReceiveNotificationStore

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. 

...

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.

...

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

Invoke the JMS publisher

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

...

You will get the following response.

Code Block
Standard :: Stock price = $149.43669233447662

...