Sample 264: Request-Response Invocations with the JMS Transport
<definitions xmlns="http://ws.apache.org/ns/synapse">
<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"/>
</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>
</definitions>
Objective
In sample 251 we saw how to perform transport switching
between HTTP and JMS using a one-way invocation. Here we will do HTTP to JMS switching
with a two-way, request-response invocation.
Executing the Client
Send a stock quote request to Synapse over HTTP using the following command.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dsymbol=MSFT
The proxy service will send the message to the JMS queue named SimpleStockQuoteService
and wait for a response to arrive. In fact the JMS sender in Synapse will create a temporary
queue to start polling on that queue for the response. The address of this queue will
be sent on the request as a JMS header. Axis2 server will consumer the request from the
queue and place a response on the temporary queue created by Synapse. At this point
Synapse will pick up the response and forward it back to the Axis2 client over HTTP.
Back to Catalog