This section explains, through an example scenario, how the Dead Letter Channel EIP can be implemented using WSO2 ESB. The following topics are covered:
Table of Contents |
---|
...
Figure 1: Dead Letter Channel EIP
Example scenario
This example takes a proxy service called StockQuoteProxy
, which fronts a service by the name SimpleStockQuoteService
. As long as the SimpleStockQuoteService
is running, the clients calling StockQuoteProxy
service get responses. But if the SimpleStockQuoteService
is down or a failure occurs while trying to send the message to the SimpleStockQuoteService
, the faultSequence
of the StockQuoteProxy
will get invoked, and the message will be forwarded to the dead letter channel.
...
Before digging into implementation details, let's take a look at the relationship between the example scenario and the Dead Letter Channel EIP by comparing their core components. We use three constructs of WSO2 ESB to implement the Dead Letter Channel EIP.
Dead Letter Channel EIP (Figure 1) | Dead Letter Channel Example Scenario (Figure 2) |
---|---|
Sender | Stock Quote Client |
Intended Recipient | Stock Quote Service Instance |
Dead Letter Channel | Store mediator, Message stores, Message processors |
Intended Receiver | Simple Stock Quote Service |
The diagram below depicts the DLC architecture in WSO2 ESB.
...
WSO2 ESB provides two message store types: in memory and JMS. Users can also define their own custom message store implementations.
- Start the ESB server and log into its management console UI (https://localhost:9443/carbon). In the management console, navigate to the Main menu and select the Message Stores sub menu in the Service Bus section.
- Create a new message store. In this example, we create
test-msg-store
.Anchor create-msg-store create-msg-store
- Define a message processor called
test-msg-processor
as follows: - Define an endpoint called
SimpleStockQuoteService
, and set it as thetarget.endpoint
property. The store mediator uses it when storing the message into the message store.
ESB configuration
Navigate to Main Menu, click Service Bus and then Source View. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view.
...
- Start the sample Axis2 server with
SimpleStockQuoteService
deployed. For instructions, refer to the section Setting Up the ESB Samples - Starting the Axis2 server in the WSO2 ESB documentation. Use SoapUI or WSO2 ESB's Try It tool to send the following request to the
getSimpleQuote
function ofStockQuoteProxy
service. For information about the Stock Quote client, refer to the section Sample Clients in the WSO2 ESB documentation.
Code Block <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples"> <soapenv:Header/> <soapenv:Body> <ser:getSimpleQuote> <!--Optional:--> <ser:symbol>IBM</ser:symbol> </ser:getSimpleQuote> </soapenv:Body> </soapenv:Envelope>
- A message similar to the one below appears in the simple Axis server.
- Stop the Axis server, and resend the same request. Note that the message sending fails, and the message processor tries to resend the message every few seconds.
- Restart the Axis server, and note that the message will be delivered to
SimpleStockQuoteService
once the server is running.
...