This documentation is for WSO2 ESB version 4.5.1. View documentation for the latest release.

Sample 13: Dual Channel Invocation through Synapse

Introduction

This sample demonstrates dual channel messaging through synapse.

Prerequisites

Refer to Prerequisites section in ESB Samples Setup page.

Building the Sample

1. Start the ESB with sample 0 configuration using the instructions given in Starting Sample ESB Configurations.

2. A message should appear in the command or text Linux console stating the server started successfully.

3. Deploy the back-end service 'SimpleStockQuoteService' and start the Axis2 server using the instructions given in section Starting Sample Back-End Services.

5. Now you have a running ESB instance and a back-end service deployed. In the next section, we will send a message to the back-end service through the ESB using a sample client.

Executing the Sample

This example invokes the same getQuote operation on the SimpleStockQuoteService using the custom client, which uses the Axis2 ServiceClient API with useSeparateListener set to true so that the response is coming through a different channel than the one which is used to send the request to a callback defined in the client.

1. The sample client used here is 'Stock Quote Client' which can operate in several modes. For instructions on this sample client and its operation modes, refer to Stock Quote Client. Run the following ant command from <ESB_HOME>/samples/axis2Client directory.

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

2. Note the dual channel invocation through Synapse into the sample Axis2 server instance, which reports the response back to the client over a different channel.

Response received to the callback
    Standard dual channel :: Stock price = $57.16686934968289

3. Send your client request through TCPmon to notice that Synapse replies to the client with a HTTP 202 acknowledgment when you send the request. The communication between synapse and the server happens on a single channel and you get the response back from synapse to the client's callback in a different channel (which cannot be observed through TCPmon).

Also note the wsa:Reply-To header as similar to http://localhost:8200/axis2/services/anonService2. This implies that the reply is in a different channel listening on the port 8200.

It is required to engage addressing, when using the dual channel invocation since the wsa:Reply-To header is required.