When you providing a solution for a enterprise you may need to dequeue from a JMS queue and send it to a SOAP endpoint. For this solution the service operation we going to invoke should be one way. So here I am explaining how you can do that easily using WSO2 ESB. Its all about a matter of creating a proxy service. You can download WSO2 ESB from
here.
Before starting the WSO2 ESB you need to enable the JMS listener by setting the configuration details of JMSListener in $WSO2ESB_HOME/repository/conf/axis2/axis2.xml. WSO2 ESB supports most of the JMS message brokers and its a just a matter of simple configuration. Here are some configuration document links.
Start the WSO2 ESB using executing the following command using command line inside $WSO2ESB_HOME/bin.
- Windows - wso2server.bat
- Linux - sh wso2server.sh
Now lest see a short diagram of what we are going to do.
Here red lines show the message flow.
Now lets see how to create the proxy service to achieve this functionality. First go to WSO2 ESB Management Console which you can access using the URL https://localhost:9443/carbon which is the default URL.
Now you need to login to the Management Console and the default username and password are admin and admin.
Now select the Main ==> Manage ==> Services ==> Add Proxy Service ==> Custom Proxy as shown in the figure below.
In the first page of the proxy configuration add a Proxy name, set the transport to jms and add the following Service Parameters categorize under General Settings.
transport.jms.ContentType :
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
transport.jms.ConcurrentConsumers : 1
transport.jms.ConnectionFactory : myTopicConnectionFactory
transport.jms.SessionTransacted : false
transport.jms.Destination : myQueue
transport.jms.MaxConcurrentConsumers : 1
You can find more details for these parameters on
here.
After filling the page will look like as following figure.
Now you are done with the first page. Click Next to go to the next page.
Here you need to configure the inSequence to send the SOAP message to your service endpoint. Here we are going to add it in line. Click Edit in Define Inline in Define In Sequence.
And add a Log mediator. You can do it by click on Add Child ==> Core ==> Log and set to log level to full. Which will log the messages comes to this Proxy endpoint.
Then add the Send mediator where we invoke the endpoint of our service. This can be done by clicking Add Child ==> Core ==> Send. Then edit the Send mediator configuration by defining the In Line endpoint and selecting address endpoint and add your service endpoint there.
Now it will be look like as following figure.
Save and Close the In sequence, then click Next.
Then click Finish and we are done with the configuration.
So if we add a message to the myQueue, then this proxy will dequeue it from the queue and send it to your endpoint.
Here is my full configuration in xml format and my service endpoint is http://localhost:7611/sample/ep1
<proxy xmlns="http://ws.apache.org/ns/synapse" name="jmsReaderProxy" transports="jms" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<send>
<endpoint>
<address uri="http://localhost:7611/sample/ep1"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConcurrentConsumers">1</parameter>
<parameter name="transport.jms.ConnectionFactory">myTopicConnectionFactory</parameter>
<parameter name="transport.jms.SessionTransacted">false</parameter>
<parameter name="transport.jms.Destination">myQueue</parameter>
<parameter name="transport.jms.MaxConcurrentConsumers">1</parameter>
<description></description>
</proxy>