This section explains, through an example scenario, how the Message Channels EIP can be implemented using the WSO2 ESB. The following topics are covered:
Introduction to Message Channels
Message Channels facilitate communication between applications. A sender adds a message to a particular channel. A receiver can then read this message. Channels allow the sender and receiver to synchronize. For more information, go to Message Channel.
Figure 1: Message Channel EIP
The following diagram depicts an example scenario that is carried out using the ESB. In this example, a stock quote is requested by a client application from a service. As shown below, the client application sends the request to the receiver through a message channel (defined in the ESB). The message channel retrieves the message content from the sender, and it allows the receiver to read the content through the channel.
Figure 2: Sample scenario of the Message Channel EIP
Before digging into implementation details, let's look at how the core components in this example scenario map to the Message Channel EIP:
|Message Channel EIP (Figure 1)||Message Channel sample Scenario (Figure 2)|
|Stock Quote Client|
|Message System||WSO2 ESB|
Stock Quote Server
The ESB configuration
Given below is the ESB configuration for simulating the example scenario explained above.
The configuration elements
The elements used in the above ESB configuration are explained below.
- <proxy> - This is the proxy service that should be invoked to execute the configuration.
- <inSequence> - A message is first received by the proxy service, and then directed to this sequence.
- <outSequence> - This sequence is triggered after the execution of the <inSequence>.
- <sequence> - This is an external sequence, which is invoked by the proxy.
- <send> - This is the Send mediator that routes the message to the endpoint indicated by the address URI.
Simulating the example scenario
Now, let's try out the example scenario explained above.
Setting up the environment
You need to set up the ESB, and the back-end service:
- Download the
MessageChannel.zipfile, which includes the ESB configuration described above.
See Setting up the Environment for instructions on setting up the ESB and the back-end service.
When you set up the environment, note that you only need to start one instance of the back-end service (Stock Quote Service) to simulate this example.
Executing the sample
Let's send a request to the ESB using the Stock Quote Client application. Find out more about the Stock Quote Client from the ESB documentation.
- Open a new terminal, and navigate to the
<ESB_HOME>/samples/axis2Client/directory. The Stock Quote client application is stored in this directory.
Execute the following command to send the request to the ESB.
Analyzing the output
When you execute the command above, the ESB first receives the message and then routes it to the back-end service (StockQuoteService). The following output will be printed on the Axis2 server's console:
The generated stock quote will then be sent to the client application (Stock Quote Client). The following output will be printed on the client application's console: