This section explains, through an example scenario, how the Request-Reply Message EIP can be implemented using the ESB profile of WSO2 EI. The following topics are covered:
Introduction to Request-Reply
The Request-Reply EIP facilitates two-way communication by ensuring that a sender gets a response or reply back from the receiver after sending a request message. This pattern sends a pair of Request-Reply messages, each on its own channel. For more information, refer to http://www.eaipatterns.com/RequestReply.html.
Figure 1: Request-Reply EIP
The example scenario illustrates how a request to a service is made through one channel, and the response from the service is returned to the requester on a separate channel.
The diagram below depicts how to simulate the example scenario using the ESB profile.
Figure 2: Example Scenario of the Request-Reply EIP
Before digging into implementation details, let's take a look at the relationship between the example scenario and the Request-Reply EIP by comparing their core components.
|Request-Reply EIP (Figure 1)||Request-Reply Example Scenario (Figure 2)|
|Requestor||Simple Stock Quote Client|
|Request Channel||Send, Endpoint|
|Replier||Stock Quote Service Instance|
|Reply Channel||Send, Endpoint|
- Download and install the ESB profile of WSO2 Enterprise Integrator (EI). For a list of prerequisites and step-by-step installation instructions, go to Installing the Product in WSO2 EI Documentation.
- Start an instance of Sample Axis2 server. For instructions, go to Starting the Axis2 server in WSO2 EI Documentation.
- Deploy the back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, go to Deploying sample back-end services in WSO2 EI Documentation.
Start the ESB profile and log into its Management Console. For instructions, see Starting the ESB profile in WSO2 EI Documentation.
On the Management Console, navigate to the Main Menu and click Source View in the Service Bus section. Copy and paste the following configuration to the source view. You can now explore the example scenario.
Simulating the sample scenario
Use a SOAP client like SoapUI to invoke the above proxy service. The following image illustrates how a response is generated to a request made by the client.
How the implementation works
Let's investigate the elements of the configuration in detail. The line numbers below are mapped with the configuration shown above.
- inSequence [line 5 in config] - When a client sends a message, it is picked up by the
- send [line 6 in config] - The
sendmediator sends the message to the endpoint running on port 9000.
- outSequence [line 12 in config] - The processed response from the endpoint will be sent back to the client through the
sendmediator inside the
outSequencewill direct the message back to the requesting client, which is on a channel separate from the requesting channel.