com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

JMS Synchronous Invocations : Dual Channel HTTP-to-JMS

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.

Prerequisites

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/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 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="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.

PropertyValue for this use caseDescription

address uri

jms:/SMSStore

The 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. 

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="http://ws.apache.org/ns/synapse"
       name="SMSForwardProxy"
       transports="jms"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <send>
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <parameter name="transport.jms.ContentType">
      <rules>
         <jmsProperty>contentType</jmsProperty>
         <default>text/xml</default>
      </rules>
   </parameter>
   <parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
   <parameter name="transport.jms.DestinationType">queue</parameter>
   <parameter name="transport.jms.Destination">SMSStore</parameter>
   <description/>
</proxy>

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: 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 <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
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.