This section describes how to configure WSO2 ESB to send messages to a JMS Queue.
Diagram 1 : Simple HTTP to JMS proxy service
The following example code shows the configuration of ESB proxy service to accept messages via HTTP and send them to JMS queue.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="http"> <target> <inSequence> <property action="set" name="OUT_ONLY" value="true"/> <send> <endpoint> <address uri=""/> <!-- Specify the JMS connection URL here --> </endpoint> </send> </inSequence> <outSequence> <send/> </outSequence> </target> <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/> </proxy>
During inSequence, the OUT_ONLY property is set to true to indicate that message exchange is one-way.
JMS Connection URL
To send a message to a JMS queue, we define a JMS connection URL (line numbers 7 in the configuration above) as the URL of the endpoint, which will be invoked via the send mediator.
You can define a JMS queue name and connection factory parameters in the JMS connection URL. Values of connection factory parameters depend on the type of the JMS broker. Listed below are examples of how the JMS connection URL can be defined for WSO2 Message Broker and for ActiveMQ.
Example JMS connection URL for ActiveMQ
jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory& java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue
Example JMS connection URL for WSO2 Message Broker
jms:/StockQuotesQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=repository/conf/jndi.properties&transport.jms.DestinationType=queue
Note
When entering these URLs in the management console, replace '&' character in the endpoint URL with '&'
Other Configurations
In addition to configuring the ESB proxy service as shown above, follow the steps below.
- To enable JMS sender in the ESB, un-comment following line in <ESB_HOME>/repository/conf/axis2/axis2.xml.
<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
- To enable JMS listeners in back-end axis2 services, edit <ESB_HOME>/samples/axis2Server/repository/conf/axis2.xml file and configure JMS listener as explained section Setting up the JMS Listener.
- To send an HTTP message to ESB proxy service, execute the following command from <ESB_HOME>/sample/axis2Client.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dmode=placeorder -Dsymbol=MSFT
- During inSequence, the OUT_ONLY property is set to true to indicate that message exchange is one-way.