Skip to end of metadata
Go to start of metadata

This section explains, through an example scenario, how the Message Store EIP can be implemented using WSO2 ESB. The following topics are covered:

Introduction to Message Store

The Message Store EIP reports against message information without disturbing the loosely coupled and transient nature of a messaging system. It stores a duplicate of a message between each flow and captures the message information in a central location. For more information, refer to http://www.eaipatterns.com/MessageStore.html.

Figure 1: Message Store EIP

Example scenario

This example scenario is a stock quote service and demonstrates how Message Stores can be used to store the state of a message between each mediation cycle. We send several stock quote requests to the ESB using a sample client, and then use the ESB management console UI to check how those messages were stored when the request was sent and a reply has arrived. 

The diagram below depicts how to simulate the example scenario using the WSO2 ESB.

Figure 2: Example Scenario of the Message Store EIP

Before digging into implementation details, let's take a look at the relationship between the example scenario and the Message Store EIP by comparing their core components.

Message Store EIP (Figure 1)Message Store Example Scenario (Figure 2)
Message StoreWSO2 ESB Message Store

Environment setup

  1. 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 Getting Started in the WSO2 ESB documentation.
  2. Start the sample Axis2 server. For instructions, refer to the section ESB Samples Setup - Starting Sample Back-End Services in the WSO2 ESB documentation.

ESB configuration

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 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.

Simulating the sample scenario

  1. Send the following request to the server several times using a SOAP client like SoapUI

  2. In the ESB management console, click the Main menu and select Message Stores sub menu under the Service Bus menu. The messages you sent will be available under message stores. You can explore their content as follows.

    Message 1

    Message 2

How the implementation works

Let's investigate the elements of the ESB configuration in detail. The line numbers below refer to the ESB configuration shown above.

  • localEntry [line 2 in ESB config] - Specifies the local entry that has the key Location and value foo
  • sequence [line 11 in ESB config] - This is the main sequence invoked when a request is sent to the ESB. It has an in mediator, which defines the mediation to perform when a request is received, and an out mediator, which defines the mediation to perform when a response is received from a back-end service. 
  • enrich [line 13 in ESB config] - The Enrich mediator applies what is in its source element to what is in its target specified as an XPath expression. In this example, it applies the plain text value inside the localEntry with key Location as a text value into the symbol element in the SOAP body.
  • store [line 17 in ESB] - The Store mediator stores the message inside the CentralStorage message store.
  • send [line 18 in ESB config] - The message is then sent to the specified endpoint. 
  • store [line 25 in ESB config] - This store mediator is in the out sequence. It stores the message received as a response from the back-end service inside the CentralStorage message store.
  • messageStore [line 29 in ESB config] - Defines a new message store with the name CentralStorage. 
  • No labels