Objective: Introduction to switching transports (JMS to HTTP/S) with Proxy Services.
- Start the Axis2 server and deploy the
- Download, install and start a JMS server, and configure ESB to listen on JMS.
- Start the Synapse configuration numbered 250:
wso2esb-samples.sh -sn 250
<proxy name="StockQuoteProxy" transports="jms">
<property action="set" name="OUT_ONLY" value="true"/>
For this example we use ActiveMQ as the JMS provider. Once ActiveMQ is installed and started you should get a message as follows:
INFO BrokerService - ActiveMQ JMS Message Broker (localhost) started
You will now need to configure the Axis2 instance used by ESB (not the sample Axis2 server) to enable JMS support using the above provider. Refer to the Axis2 documentation on setting up JMS for more details (http://ws.apache.org/axis2/1_1/jms-transport.html). You must also copy activemq-core-5.7.0.jar, geronimo-j2ee-management_1.1_spec-1.0.1.jar, and geronimo-jms_1.1_spec-1.1.1.jar from
<ESB_HOME>/repository/components/lib to allow the ESB to connect to the JMS provider.
For a default ActiveMQ version 4.0 installation, you may uncomment the Axis2 transport listener configuration found at
<transportReceiver name="jms"> ...
You need to enable the JMS transport sender for the ESB to be able to send messages over the JMS transport. To enable the JMS transport sender, uncomment the Axis2 transport sender configuration found at
<transportSender name="jms" />
Once you start the Synapse configuration and request for the WSDL of the proxy service (http://localhost:8280/services/StockQuoteProxy?wsdl) you will notice that its exposed only on the JMS transport. This is because the configuration specified this requirement in the Proxy Service definition.
Now lets send a stock quote request on JMS, using the dumb stock quote client as follows:
ant jmsclient -Djms_type=pox -Djms_dest=dynamicQueues/StockQuoteProxy -Djms_payload=MSFT
On the ESB debug log, you will notice that the JMS listener received the request message as:
[JMSWorker-1] DEBUG ProxyServiceMessageReceiver -Proxy Service StockQuoteProxy received a new message...
Now if you examine the console running the sample Axis2 server, you will see a message indicating that the server has accepted an order as follows:
Accepted order for : 16517 stocks of MSFT at $ 169.14622538721846
In this sample, client sends the request message to the proxy service exposed in JMS in Synsape. ESB forwards this message to the HTTP EPR of the simple stock quote service hosted on the sample Axis2 server, and returns the reply back to the client through a JMS temporary queue.
It is possible to instruct a JMS Proxy Service to listen to an already existing destination without creating a new one. To do this, use the property elements on the proxy service definition to specify the destination and connection factory etc.
<property name="transport.jms.Destination" value="dynamicTopics/something.TestTopic"/>
Example of switching transports in WSO2 ESB.