Switching from HTTP(S) to JMS¶
This example demonstrates how WSO2 Micro Integrator receives messages in HTTP and passes the messages through JMS. The Micro Integrator uses a proxy service over HTTP, forwards the received messages to the EPR using JMS, and immediately responds with a 202.
If the previous example on JMS to HTTP is also configured, it will pick the message from queue and send it to the stockquote proxy.
Synapse configuration¶
Following are the integration artifacts (proxy service) that we can use to implement this scenario. See the instructions on how to build and run this example.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="HTTPtoJMSStockQuoteProxy" transports="http">
<target>
<endpoint>
<address uri="jms:/Queue1?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"/>
</endpoint>
<inSequence>
<property action="set" name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL key="conf:HTTP_JMS/sample_proxy_1.wsdl" preservePolicy="true"/>
</proxy>
Example JMS connection URL for WSO2 MB
jms:/Queue1?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=conf/jndi.properties&transport.jms.DestinationType=queue
Build and Run¶
Create the artifacts:
- Set up WSO2 Integration Studio.
- Create an integration project with an ESB Configs module and an Composite Exporter.
- Add sample_proxy_1.wsdl as a registry resource (change the registry path of the proxy accordingly).
- Create the proxy service with the configurations given above.
- Deploy the artifacts in your Micro Integrator.
- Configure MI with the selected message broker and start the Micro-Integrator.
Invoke the HTTPtoJMSStockQuoteProxy with the following payload (using SOAP UI or CURL):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<m0:placeOrder xmlns:m0="http://services.samples">
<m0:order>
<m0:price>172.23182849731984</m0:price>
<m0:quantity>18398</m0:quantity>
<m0:symbol>IBM</m0:symbol>
</m0:order>
</m0:placeOrder>
</soapenv:Body>
</soapenv:Envelope>
Sample CURL:
curl -X POST \
http://localhost:8290/services/HTTPtoJMSStockQuoteProxy.HTTPtoJMSStockQuoteProxyHttpSoap11Endpoint \
-H 'cache-control: no-cache' \
-H 'content-type: text/xml' \
-H 'soapaction: \"urn:placeOrder\"' \
-d '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<m0:placeOrder xmlns:m0="http://services.samples">
<m0:order>
<m0:price>172.23182849731984</m0:price>
<m0:quantity>18398</m0:quantity>
<m0:symbol>IBM</m0:symbol>
</m0:order>
</m0:placeOrder>
</soapenv:Body>
</soapenv:Envelope>'
Now, the message count in the queue should be increased. If the JMS listener is also setup, it should pick the message from the queue and send to the stockquote proxy.
Top