Versions Compared

Key

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

...

Generally, JMS is used for one-way, asynchronous message exchange. However you can perform synchronous messaging also with JMS. Described below is how to configure WSO2 ESB for two-way and quad-channel synchronous messaging.

JMS Synchronous Invocations : Dual Channel HTTP-to-JMS
Anchor
Dual
Dual


Diagram 4 : Dual-channel JMS synchronous invocations

...

Code Block
languagehtml/xml
titleExample code 4
<proxy name="StockQuoteProxy" transports="http">
      <target>
          <endpoint>
                  <address uri="jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;                 java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=queue&amp;transport.jms.ReplyDestination=SimpleStockQuoteServiceReply"/>
          </endpoint>
          <inSequence>
              <property action="set" name="transport.jms.ContentTypeProperty" value="Content-Type" scope="axis2"/>
          </inSequence>
          <outSequence>
              <property action="remove" name="TRANSPORT_HEADERS" scope="axis2"/>
              <send/>
          </outSequence>
      <target>
      <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>

In the above example code, the The message flow of the sample code is as follows:

  1. The ESB proxy service accepts messages via HTTP and places them in SimpleStockQuoteService JMS queue.
  2. The back-end consumes these messages from the queue and places response messages in the SimpleStockQuoteServiceReply queue.
  3. When a reply is available in the SimpleStockQuoteServiceReply queue, the ESB proxy will pick the response message and send it as the response to the client via HTTP connection.

...

To send a HTTP message to the ESB proxy service, execute following command from <ESB_HOME>/sample/axis2Client directory. 

...

The response queue name is defined using transport.jms.ReplyDestination parameter in the JMS connection URL.

JMS Synchronous Invocations : Quad Channel JMS-to-JMS
Anchor
Quad
Quad

 Diagram 5 : Quad-channel JMS synchronous invocations

...

Code Block
languagehtml/xml
titleExample Code 5
<proxy name="QuadJMS" transports="jms">
      <target>
          <inSequence>
              <property action="set" name="transport.jms.ContentTypeProperty" value="Content-Type" scope="axis2"/>
              <send>
                  <endpoint>
                      <address uri="jms:/BEReq?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;                 java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=queue&amp;transport.jms.ReplyDestination=BERes"/>
                  </endpoint>
              </send>
          </inSequence>
          <outSequence>
              <send/>
          </outSequence>
      <target>
      <parameter name="transport.jms.Destination">ClientReq</parameter>
</proxy>

The message flow of the above sample code is as follows:

...