Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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)
SenderStock Quote Client
Intended RecipientStock Quote Service Instance
Dead Letter ChannelStore mediator, Message stores, Message processors
Intended ReceiverSimple 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.

  1. 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.
  2. Create a new message store. In this example, we create test-msg-store.
    Anchor
    create-msg-store
    create-msg-store


  3. Define a message processor called test-msg-processor as follows:

       
  4. Define an endpoint called SimpleStockQuoteService, and set it as the target.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. 

...

  1. 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.
  2. Use SoapUI or WSO2 ESB's Try It tool to send the following request to the getSimpleQuote function of StockQuoteProxy service. For information about the Stock Quote client, refer to the section Sample Clients in the WSO2 ESB documentation.


    Image Removed

     

    the
    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>
  3. A message similar to the one below appears in the simple Axis server.

    Image Added
  4. 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.
  5. Restart the Axis server, and note that the message will be delivered to SimpleStockQuoteService once the server is running.

...