The content in this documentation is for older versions of WSO2 products. For updated information on Enterprise Integration Patterns, go to the latest Micro Integrator documentation. "> The content in this documentation is for older versions of WSO2 products. For updated information on Enterprise Integration Patterns, go to the latest Micro Integrator documentation.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 46 Next »

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

Introduction to Message Endpoint

The Message Endpoint EIP encapsulates the messaging system from the rest of the application and customizes a general messaging API for a specific application and task. Therefore, you can change the message API just by changing the endpoint code. This improves the maintainability of applications.

For more information, go to Message Endpoint.







Figure 1: Message Endpoint EIP

Example scenario

The example scenario is an inventory for stocks. It illustrates how a stock quote is generated when a request is sent to the ESB. The sender sends the request to the ESB, where the request is then diverted to the stock quote service. The diagram below depicts how to simulate the example scenario using the ESB.

Figure 2: Example scenario of the Message Endpoint EIP

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

Message Endpoint EIP (Figure 1)Message Endpoint Example Scenario (Figure 2)

Data

Stock Quote Request

Message Endpoint

WSO2 ESB

Receiver Application  

Stock Quote service

The ESB configuration

Given below is the ESB configuration for simulating the example scenario explained above.

 

<definitions xmlns="http://ws.apache.org/ns/synapse">
   <!-- Will trigger when the message is sent to message-endpoint-proxy -->
   <proxy name="message-endpoint-proxy" startOnLoad="true" transports="http https">
       <target>
           <inSequence>
               <!-- Sends the message to the specified service -->
               <send>
                   <endpoint>
                       <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                   </endpoint>
               </send>
           </inSequence>
           <outSequence>
               <respond/>
           </outSequence>
       </target>
   </proxy>
</definitions>

The configuration elements

The elements used in the above ESB configuration are explained below.

  • <proxy> - This is the proxy service that should be invoked to execute the configuration.
  • <inSequence> - A message is first received by the proxy service, and then directed to this sequence.
  • <endpoint> - The destination to which the message will be sent.
  • <outSequence> - This sequence is triggered after the execution of the <inSequence>.

Simulating the example scenario

Now, let's try out the example scenario explained above.

Setting up the environment

You need to set up the ESB, and the back-end service:

  1. Download the Message-Endpoint_1.0.0.zip file, which includes the ESB configuration described above. 
  2. See Setting up the Environment for instructions on setting up the ESB and the back-end service.

Executing the sample

Send the following request to the ESB, by using a SOAP client:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:getQuote>    
         <ser:request>          
            <xsd:symbol>foo</xsd:symbol>
         </ser:request>         
      </ser:getQuote>
   </soapenv:Body>
</soapenv:Envelope>

Analyzing the output

When you send the request, the ESB first receives the message and then routes it to the back-end service (StockQuoteService). The following output will be printed on the Axis2 server's console, confirming that the request is successfully received by the back-end service.

samples.services.SimpleStockQuoteService :: Generating quote for : foo

You can view the response in the SOAP UI as follows:

  • No labels