...
Diagram 4 : Dual-channel JMS synchronous invocations
The following example code shows configuration of WSO2 ESB for dual-channel JMS synchronous invocations.
Code Block | ||||
---|---|---|---|---|
| ||||
<proxy name="StockQuoteProxy" transports="http">
<target>
<endpoint>
<address uri="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&transport.jms.ReplyDestination=SimpleStockQuoteServiceReply"/>
</endpoint>
<inSequence>
<property action="set" name="transport.jms.ContentTypeProperty" value="Content-Type" scope="axis2"/>
</inSequence>
<outSequence>
<property action="remove" name="TRANSPORT_HEADERS" scope="axis2"/>
<send/>
</outSequence>
<target>
<publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
</proxy> |
In the above example code, the ESB proxy service accepts messages via HTTP and places them in SimpleStockQuoteService JMS queue. The back-end consumes these messages from the queue and places response messages in the SimpleStockQuoteServiceReply queue. When a reply is available in the SimpleStockQuoteServiceReply queue, the ESB proxy will pick the response message and send it as the response to the client via HTTP connection.
To send a HTTP message to the ESB proxy service, execute following command from <ESB_HOME>/sample/axis2Client directory.
Code Block |
---|
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dmode=placeorder -Dsymbol=MSFT |
To co-relate request and response JMS messages, the ESB uses a JMS correlation ID internally. For more information, refer to section
Since this is a two-way invocation, the inSequence does not have the following configuration: <property action="set" name="OUT_ONLY" value="true"/>
Response queue name is defined using transport.jms.ReplyDestination parameter in JMS connection URL.