Sample 12: One-way Messaging / Fire-and-Forget Through Synapse

<definitions xmlns="http://ws.apache.org/ns/synapse"> <sequence name="main"> <!-- filtering of messages with XPath and regex matches --> <filter source="get-property('To')" regex=".*/StockQuote.*"> <then> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> <drop/> </then> </filter> <send/> </sequence> </definitions>

Objective

Demonstrate the ability to perform one-way invocations (out-only) through Synapse.

Pre-requisites

  • Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
  • This sample makes use of the configuration used in sample 1. So start Synapse using the configuration numbered 1 (repository/conf/sample/synapse_sample_1.xml)
    Unix/Linux: sh synapse.sh -sample 1
    Windows: synapse.bat -sample 1

Executing the Client

In this example we will invoke the one-way 'placeOrder' operation on the SimpleStockQuoteService using the sample client which uses the Axis2 ServiceClient.fireAndForget() API. To send a placeOrder request from the sample client, execute the following command.

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=placeorder

Going through the Axis2 server logs, you will notice the following entry, which confirms that Axis2 accepted the in-only request.

SimpleStockQuoteService :: Accepted order for : 7482 stocks of IBM at $ 169.27205579038733

If you send your client request through TCPmon, you will notice that the SimpleStockQuoteService replies to Synapse with a HTTP 202 reply, and that Synapse in turns replies to the client with a HTTP 202 acknowledgment.

Back to Catalog