About Pascal Alma

Pascal is a senior JEE Developer and Architect at 4Synergy in The Netherlands. Pascal has been designing and building J2EE applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Specialties: JEE, SOA, Mule ESB, Maven, Cloud Technology, Amazon AWS.

Starting with WSO2 ESB by running the samples

I recently joined a new assignment where we have to implement an ESB solution based on the WSO2 toolstack. Although I am familiair with most of the concepts of the ESB and some other implementations (like Mule ESB) it is the first time I will have to work with the WSO2 ESB. Luckily there is a lot of documentation to find and the tool comes with a large amount of samples how to use the ESB. In this post I show the steps I took to make the first examples work. For a more thorough explanation see the information here.

The first step is to download and install the ESB, which is really easy. You can download the zip here. After downloading simply extract it to the location where you want to install the tool. I installed it in the directory
‘Users/pascal/develop/wso2esb-4.5.1?. After unzipping you will see the file ‘INSTALL.txt’ in the unzipped folder. In this file all information is stated how to start and stop the ESB. To work with the samples you will have to start the ESB with the command:

./wso2esb-samples.sh -sn ${sample-number}

where ‘${sample-number}’ is the sample number you want to run. So to run the ESB with sample 1 just start the ESB with the command:

'./wso2esb-samples.sh -sn 1'

and you will see logging like this:

Screen Shot 2013-03-02 at 15.29.50

Please note that I set the log level to DEBUG for ‘org.apache.synapse’ package by modifying the ‘log4j.properties’ that can be found in the directory ‘$CARBON_HOME/repository/conf/’. The first examples are mostly based on proxying or redirecting to existing services. These services are based on Axis2 and also supplied with the installation of the WSO2 ESB. To start the Axis2 server open a new terminal window, browse to the directory ‘$CARBON_HOME/samples/axis2Server’ and execute the command ‘./axis2server.sh’. This starts the SimpleAxisServer as can be seen in the console in the logging:

Screen Shot 2013-03-03 at 16.16.29

If you open a browser and navigate to 'http://localhost:9000/services' you will see that we currently have no service running:

Screen Shot 2013-03-03 at 16.19.12

To deploy a service, for example the SimpleStockQuoteService, open a new terminal and navigate to the following directory: $CARBON+HOME/samples/axis2Server/src/SimpleStockQuoteService. In here simply supply the ‘ant’ command and the service is compiled, built and deployed to the Axis2Server we started earlier:

Screen Shot 2013-03-03 at 16.25.17

Now if we look at 'http://localhost:9000/services' we see the SimpleStockService being available for requests:

Screen Shot 2013-03-03 at 16.28.00

If you want you can test the service with SoapUI:

Screen Shot 2013-03-03 at 16.36.25

So now we have the server side ready for the first examples. Lets run the client. Each sample has documentation which states how to run the Axis2 client. For sample 1 the documentation shows this:

Screen Shot 2013-03-03 at 16.45.12

Open up a new terminal, browse to the following directory ‘/Users/pascal/develop/wso2esb-4.5.1/samples/axis2Client’ and supply the stated command to run the client:

Screen Shot 2013-03-03 at 16.55.44

As you see we received a quote for the stock IBM. In the terminal running the WSO2 ESB we see the following logging caused by the incoming request:

[2013-03-03 16:58:03,113] DEBUG - SynapseMessageReceiver Synapse received a new message for message mediation...
[2013-03-03 16:58:03,114] DEBUG - SynapseMessageReceiver Received To: /services/StockQuote
[2013-03-03 16:58:03,114] DEBUG - SynapseMessageReceiver SOAPAction: urn:getQuote
[2013-03-03 16:58:03,114] DEBUG - SynapseMessageReceiver WSA-Action: urn:getQuote
[2013-03-03 16:58:03,114] DEBUG - Axis2SynapseEnvironment Injecting MessageContext
[2013-03-03 16:58:03,115] DEBUG - Axis2SynapseEnvironment Using Main Sequence for injected message
[2013-03-03 16:58:03,115] DEBUG - SequenceMediator Start : Sequence <main>
[2013-03-03 16:58:03,115] DEBUG - SequenceMediator Sequence <SequenceMediator> :: mediate()
[2013-03-03 16:58:03,115] DEBUG - InMediator Start : In mediator
[2013-03-03 16:58:03,115] DEBUG - InMediator Current message is incoming - executing child mediators
[2013-03-03 16:58:03,115] DEBUG - InMediator Sequence <InMediator> :: mediate()
[2013-03-03 16:58:03,115] DEBUG - FilterMediator Start : Filter mediator
[2013-03-03 16:58:03,116] DEBUG - FilterMediator Source : get-property('To') against : .*/StockQuote.* matches - executing child mediators
[2013-03-03 16:58:03,116] DEBUG - FilterMediator Sequence <FilterMediator> :: mediate()
[2013-03-03 16:58:03,116] DEBUG - SendMediator Start : Send mediator
[2013-03-03 16:58:03,116] DEBUG - EndpointContext Checking if endpoint : endpoint_d06dafda969c8e11992a8e8f5366fd33203399eaae89984c currently at state ACTIVE can be used now?
[2013-03-03 16:58:03,116] DEBUG - AddressEndpoint Sending message through endpoint : endpoint_d06dafda969c8e11992a8e8f5366fd33203399eaae89984c resolving to address = http://localhost:9000/services/SimpleStockQuoteService
[2013-03-03 16:58:03,116] DEBUG - AddressEndpoint SOAPAction: urn:getQuote
[2013-03-03 16:58:03,116] DEBUG - AddressEndpoint WSA-Action: urn:getQuote
[2013-03-03 16:58:03,117] DEBUG - Axis2FlexibleMEPClient Sending [add = false] [sec = false] [rm = false] [mtom = false] [swa = false] [format = null] [force soap11=false] [force soap12=false] [pox=false] [get=false] [encoding=null] [to=http://localhost:9000/services/SimpleStockQuoteService]
[2013-03-03 16:58:03,117] DEBUG - Axis2FlexibleMEPClient Message [Original Request Message ID : urn:uuid:381071f8-c6ca-4e14-bfe4-0e53de7f7cc2] [New Cloned Request Message ID : urn:uuid:503aabca-2a04-413f-ba44-b6c623bf9db6]
[2013-03-03 16:58:03,117] DEBUG - SynapseCallbackReceiver Callback added. Total callbacks waiting for : 1
[2013-03-03 16:58:03,119] DEBUG - SendMediator End : Send mediator
[2013-03-03 16:58:03,120] DEBUG - DropMediator Start : Drop mediator
[2013-03-03 16:58:03,120] DEBUG - DropMediator End : Drop mediator
[2013-03-03 16:58:03,120] DEBUG - FilterMediator End : Filter mediator 
[2013-03-03 16:58:03,120] DEBUG - InMediator End : In mediator
[2013-03-03 16:58:03,120] DEBUG - SequenceMediator End : Sequence <main>
[2013-03-03 16:58:03,130] DEBUG - SynapseCallbackReceiver Callback removed for request message id : urn:uuid:503aabca-2a04-413f-ba44-b6c623bf9db6. Pending callbacks count : 0
[2013-03-03 16:58:03,132] DEBUG - SynapseCallbackReceiver Synapse received an asynchronous response message
[2013-03-03 16:58:03,133] DEBUG - SynapseCallbackReceiver Received To: null
[2013-03-03 16:58:03,133] DEBUG - SynapseCallbackReceiver SOAPAction: 
[2013-03-03 16:58:03,133] DEBUG - SynapseCallbackReceiver WSA-Action: 
[2013-03-03 16:58:03,134] DEBUG - SynapseCallbackReceiver Body : 
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><ns:getQuoteResponse xmlns:ns='http://services.samples'><ns:return xmlns:ax21='http://services.samples/xsd' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ax21:GetQuoteResponse'><ax21:change>4.155006565416989</ax21:change><ax21:earnings>-8.118428276798063</ax21:earnings><ax21:high>84.31871512134151</ax21:high><ax21:last>80.49639852693167</ax21:last><ax21:lastTradeTimestamp>Sun Mar 03 16:58:03 CET 2013</ax21:lastTradeTimestamp><ax21:low>-79.94179251359746</ax21:low><ax21:marketCap>-6855110.427635921</ax21:marketCap><ax21:name>IBM Company</ax21:name><ax21:open>83.68193468970854</ax21:open><ax21:peRatio>23.68015151185118</ax21:peRatio><ax21:percentageChange>-5.440098733913549</ax21:percentageChange><ax21:prevClose>-76.37741093768571</ax21:prevClose><ax21:symbol>IBM</ax21:symbol><ax21:volume>16034</ax21:volume></ns:return></ns:getQuoteResponse></soapenv:Body></soapenv:Envelope>
[2013-03-03 16:58:03,134] DEBUG - Axis2SynapseEnvironment Injecting MessageContext
[2013-03-03 16:58:03,135] DEBUG - Axis2SynapseEnvironment Using Main Sequence for injected message
[2013-03-03 16:58:03,135] DEBUG - SequenceMediator Start : Sequence <main>
[2013-03-03 16:58:03,135] DEBUG - SequenceMediator Sequence <SequenceMediator> :: mediate()
[2013-03-03 16:58:03,135] DEBUG - InMediator Start : In mediator
[2013-03-03 16:58:03,135] DEBUG - InMediator Current message is a response - skipping child mediators
[2013-03-03 16:58:03,135] DEBUG - InMediator End : In mediator
[2013-03-03 16:58:03,135] DEBUG - OutMediator Start : Out mediator
[2013-03-03 16:58:03,136] DEBUG - OutMediator Current message is outgoing - executing child mediators
[2013-03-03 16:58:03,136] DEBUG - OutMediator Sequence <OutMediator> :: mediate()
[2013-03-03 16:58:03,136] DEBUG - SendMediator Start : Send mediator
[2013-03-03 16:58:03,136] DEBUG - SendMediator Sending response message using implicit message properties..
Sending To: http://www.w3.org/2005/08/addressing/anonymous
[2013-03-03 16:58:03,138] DEBUG - SendMediator End : Send mediator
[2013-03-03 16:58:03,138] DEBUG - OutMediator End : Out mediator
[2013-03-03 16:58:03,138] DEBUG - SequenceMediator End : Sequence <main>

And finally in the Axis2Server terminal we see the following line added to the logging because of the request which is passed to port 9000 by the sample flow:

Sun Mar 03 16:58:03 CET 2013 samples.services.SimpleStockQuoteService :: Generating quote for : IBM

This shows that the sample is running correctly and all expected actions take place. Next step will be going through all other examples to get a better understanding of the possibilities of the WSO2 ESB.

Reference: Starting with WSO2 ESB by running the samples from our JCG partner Pascal Alma at the The Pragmatic Integrator blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below: