This section explains, through an example scenario, how the Invalid Message Channel EIP can be implemented using WSO2 ESB. The following topics are covered:
Introduction to Invalid Message Channel
The Invalid Message Channel EIP pattern allows administrators to define an error indication that appears when an endpoint fails to process a request. For more information, refer to http://www.eaipatterns.com/InvalidMessageChannel.html.
Figure 1: Invalid Message Channel EIP
The example scenario creates a deliberate error situation to demonstrate how the ESB handles errors on message failures. It requires a live Axis2 server instance to successfully provide a response to the sender, and the server instance will be shut down before sending a request. You will observe how the ESB directs the process to the
faultsequence mediator, which indicates the message invalidity to the user.
The diagram below depicts how to simulate the example scenario using the WSO2 ESB.
Figure 2: Example Scenario of the Invalid Message Channel EIP
Before digging into implementation details, let's take a look at the relationship between the example scenario and the Invalid Message Channel EIP by comparing their core components.
|Invalid Message Channel EIP (Figure 1)||Invalid Message Channel Example Scenario (Figure 2)|
|Sender||Stock Quote Client|
|Receiver||Stock Quote Service Instance|
|Invalid Message Channel||FaultSequence|
- Download and install WSO2 ESB from http://wso2.com/products/enterprise-service-bus. For a list of prerequisites and step-by-step installation instructions, refer to Installation Guide in the WSO2 ESB documentation.
- Start the sample Axis2 server. For instructions, refer to the section Starting the ESB Samples - Starting the Axis2 server in the WSO2 ESB documentation.
Start the ESB server and log into its management console UI (
//). In the management console, navigate to the Main menu and click Source View in the Service Bus section. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view.
When the server receives a request and the endpoint referred through the ESB is unavailable, the server triggers an error message. The ESB diverts the response to the invalid message channel.
Simulating the sample scenario
Pass the following message to the WSO2 ESB. You can use SoapUI or WSO2 ESB's Try It tool. To invoke the Try It tool, log into the ESB management console, navigate to the Services menu under the Main menu and select the List sub menu. Then select InvalidMessageChannelProxy and pass the following request to the ESB.
How the implementation works
Let's investigate the elements of the ESB configuration in detail. The line numbers below are mapped with the ESB configuration shown above.
- Proxy Service [line 3 of ESB config] - Defines the proxy service
InvalidMessageChannelProxywith a target endpoint to the back end service.
- faultSequence [line 14 of ESB config] - Defines a fault sequence to execute in the event of a fault. It acts as the Invalid Message Channel for this EIP. In this example configuration, we log the fault as an error, but you can place any of the usual mediators inside this sequence. For example, you could pass the invalid message to another service or back to the client.