Thursday, July 21, 2016

Publishing and Reading from JMS Queue using WSO2 ESB and WSO2 Message Broker

Integrate WSO2 ESB and MB using the following instructions:

https://docs.wso2.com/display/MB310/Integrating+WSO2+ESB

Be mindful to uncomment the  transportReceiver relevant to WSO2 MB which has  the comment "JMS transport support with WSO2 MB [version]".

Reading from a queue using an ESB proxy:

Create the following ESB proxy:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="validRequests"
       transports="http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="OUT_ONLY" value="true"/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      <endpoint>
         <address uri=[enter uri to foward the message to a specific uri]/>
      </endpoint>
   </target>
   <description/>
</proxy>


This will create a proxy named validRequests as well as a JMS queue named validRequests in the message broker. You can view this queue by logging into the WSO2 Message Broker and navigation to 'List' under 'Queues'

If you want to read from an existing queue you can simply create the proxy with the same queue name 

Writing to a queue from the ESB:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="StockQuoteProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="OUT_ONLY" value="true"/>
         <send>
            <endpoint>
               <address uri="jms:/validRequests?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"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
   <description/>
</proxy>




adf


This creates a proxy service that would simply forward the request to a JMS queue on WSO2 MB named "validRequests"

The property named OUT_ONLY indicates that the ESB will not return a response and will only do an out only invocation from the proxy service.

Creating a queue without creating a proxy:
To create a queue without creating a proxy add it in E:\WSO2\ESB\wso2esb-4.9.0\repository\conf\jndi.properties OR simply add it through the MB's management console.

--