This section explains, through an example scenario, how the Invalid Message Channel EIP can be implemented using the ESB profile of WSO2 EI. 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, go to Invalid Message Channel.
Figure 1: Invalid Message Channel EIP
The example scenario creates a deliberate error situation to demonstrate how the ESB profile 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 profile 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 ESB profile.
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 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.
<!-- Invalid Message Chanel Proxy-->
<log level="full" />
<log level="full" />
<property name="MESSAGE" value="Failure Message..."/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
When the server receives a request and the endpoint referred through the ESB profile is unavailable, the server triggers an error message. The ESB profile diverts the response to the invalid message channel.
Simulating the sample scenario
Pass the following message to the ESB profile. You can use SoapUI or the ESB profile's Try It tool. To invoke the Try It tool, log into the Management Console of the ESB profile, 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 profile.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
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.
- Proxy Service [line 3 of config] - Defines the proxy service
InvalidMessageChannelProxy with a target endpoint to the back end service.
- faultSequence [line 14 of 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.