Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

This sample demonstrates how a message can be passed through the WSO2 ESB and logged before it is delivered to its receiver. This is a basic, introductory usecase of WSO2 ESB. In this sample, we will deploy a sample client and a sample back-end service and transfer a message to the back-end service from the client through the WSO2 ESB.

Prerequisites

To install WSO2 ESB and run the sample, you need:

  • Java Development Kit/JRE version 1.6.* or 1.7.*
  • Apache Ant 1.7.0 or later.

Setup instructions are given in section Installation PrerequisitesRefer to Prerequisites section in ESB Samples Setup page.

Building the Sample

But to build and run samples, 1. Start the ESB should be started with a sample configuration by executing wso2esb-samples.bat (for Windows) or wso2esb-samples.sh (for Linux) script found in <ESB_HOME>/bin directory. The sample configurations for ESB can be found in <ESB_HOME>/repository/samples directory.1. Since this is sample 0 , execute the following command to start the Synapse configuration numbered 0. It will start an instance of the ESB in the configuration used for this sample.

On text Linux console:

Code Block
wso2esb-samples.sh -sn 0

On Windows command prompt:

...

configuration using the instructions given in Starting Sample ESB Configurations.

2. A message will should appear on in the command or text Linux console if stating the server started successfully.

3. Next, deploy the back-end service SimpleStockQuoteService.

Building the Sample

Run ESB in debug mode.

Go to the bin directory of the distribution and run the build.xml file which resides in that directory using Apache Ant.

Executing the Sample

 The synapse configuration in the ESB used for message mediation in this sample is provided in <ESB_HOME>/repository/samples/synapse_sample_0.xml as shown below:

Code Block
languagehtml/xml
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <sequence name="main">
        <in>
            <!-- log all attributes of messages passing through -->
            <log level="full"/>
            <!-- Send the message to implicit destination -->
            <send/>
        </in>
        <out>
            <!-- log all attributes of messages passing through -->
            <log level="full"/>
            <!-- send the message back to the client -->
            <send/>
        </out>
    </sequence>
</definitions>

 

The Stock quote client can operate in the following modes for this example:

Smart Client mode

4. Deploy the back-end service 'SimpleStockQuoteService' and start the Axis2 server using the instructions given in section Starting Sample Back-End Services.

5. Now you have a running ESB instance and a back-end service deployed. In the nest section, we will send a message to the back-end service through the ESB using a sample client.

Executing the Sample

1. The sample client used here is 'Stock Quote Client' which can operate in several modes. For instructions on this sample client and its operation modes, refer to Stock Quote Client. Run each of the following ant command from <ESB_HOME>/samples/axis2Client directory to trigger a sample message to the back-end service. If the message is mediated successfully, it should display an output on the Axis2 server's start-up console.

Smart Client Mode
Code Block
languagebash
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/
Using ESB as a HTTP Proxy
Code Block
languagebash
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dprxurl=http://localhost:8280/
Gateway Mode / Dumb Client

Refer to Sample 1 Simple Content-Based Routing (CBR) of Messages. 

Execute the Smart Client

By tracing the execution of ESB with the log output level set to DEBUG, you will see the client request arriving at ESB with a WS-Addressing To set to EPR http://localhost:9000/services/SimpleStockQuoteService.The ESB engine logs the message at the "full" log level (all the message headers and the body) then sends the message to its implicit To address which is http://localhost:9000/services/SimpleStockQuoteService.You will see a message in the Axis2 server console confirming that the message got routed to the sample server and the sample service hosted at the sample server generating a stock quote for the requested symbol.

...