Versions Compared

Key

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

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

Table of Contents

...

This example is a stock quote service where a client sends a stock quote request to WSO2 the ESB with profile with a return address embedded in the message header, which will indicate to the replier where the response message should be sent.

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

Figure 2: Example Scenario of the Return Address EIP

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

Return Address EIP (Figure 1)
Return Address Example Scenario (Figure 2)
Requestor 1Stock Quote Client Instance
Request Channel 1Send Mediator
Requestor 2Stock Quote Client Instance
Request Channel 2Send Mediator
ReplierStock Quote Service Instance

Environment setup

  1. Download and install
  2. WSO2 ESB from http://wso2.com/products/enterprise-service-bus.
  3. the ESB profile of WSO2 Enterprise Integrator (EI). For a list of prerequisites and step-by-step installation instructions,
  4. refer to Installation Guide in the WSO2 ESB documentation
  5. go to Installing the Product in WSO2 EI Documentation.
  6. Start
  7. the sample
  8. an instance of Sample Axis2 server. For instructions,
  9. refer to the section Setting Up the ESB Samples -
  10. go to Starting the Axis2 server in WSO2 EI Documentation.
  11. Deploy the
  12. WSO2 ESB documentation
  13. back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, go to Deploying sample back-end services in WSO2 EI Documentation.
  14. Download Return-Address.zip file.

ESB configuration

Start the ESB server and profile 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.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. 

Anchor
step3
step3

Code Block
languagehtml/xml
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
   <sequence name="main">
      <in>
         <log level="full"/>
         <send/>
      </in>
      <out>
         <log level="full"/>
         <send/>
      </out>
   </sequence>
</definitions>

Simulating the sample scenario

  1. Send

    Execute the following command to send a request using

    the

    the Stock Quote

    client to WSO2 ESB in the following manner. For information about the Stock Quote client, refer to the Sample Clients section in the WSO2 ESB documentation.
    ant stockquote

    Client to the ESB profile: 

    For information on the Stock Quote Client and its operation modes, go to Stock Quote Client in the WSO2 EI Documentation.

    ant stockquote -Daddurl=http://localhost:9000/

    soap

    services/SimpleStockQuoteService

    -Dtrpurl=http://localhost:8280/

    services/ReturnAddressProxy -Dmode=dualquote

    -Dsymbol=foo

  2. If you use TCPmon to analyze the message passing, you will notice that the client sends the following message. Note that in line 4, the WS-Addressing ReplyTo header is set to a service called anonService2. Since the reply is made to this service on a separate channel, the client will receive no response.

    Code Block
    languagehtml/xml
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
          <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
             <wsa:To>http://localhost:9000/service/SimpleStockQuoteService</wsa:To>
             <wsa:ReplyTo>
                <wsa:Address>http://10.150.3.53:8200/axis2/services/anonService2/</wsa:Address>
             </wsa:ReplyTo>
             <wsa:MessageID>urn:uuid:9aa8e783-2eb7-4649-9d36-a7fb3ad17abd</wsa:MessageID>
             <wsa:Action>urn:getQuote</wsa:Action>
          </soapenv:Header>
          <soapenv:Body>
             <m0:getQuote xmlns:m0="http://services.samples">
                <m0:request>
                   <m0:symbol>foo</m0:symbol>
                </m0:request>
             </m0:getQuote>
          </soapenv:Body>
       </soapenv:Envelope> 

    Axis2 Client Response:

    Standard dual channel :: Stock price = $78.11501844382737

    Axis2 Server Response:

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

How the implementation works

Let's investigate the elements of the ESB configuration in detail. The line numbers below are mapped with the ESB configuration shown above.

  • send [line 10 in ESB config] - The send mediator forwards messages to the address implied in the ReplyTo header field by default, unless it is made explicit that the reply should go to a specific address by using an endpoint mediator.