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.

One way messaging with WSO2 ESB

As I posted before I am currently working with the WSO2 ESB. To get a good understanding of this ESB I have been walking through the samples (haven’t finished all of them yet). Example 12 is about one-way messaging with the ESB and makes use the TCP Monitor to make it visible. I have described before how to setup a similar tool called ‘TcpTunnelGUI’ but actually I prefer the TCP Monitor. To use the tool see the manual here or here. By the way, the tool is available with the WSO2 ESB installation so you don’t have to download it and install it. Simply go to the ‘$CARBON_HOME/bin’ directory and give the command:./tcpmon.sh
 
 
 
 
To see the example 12 in action with Tcp Monitor do the following:

    • Start the WSO2 ESB

This example uses the ESB setup that is similar as the one for example 1 so start the ESB by navigating to the ‘$CARBON_HOME/bin’ directory in a terminal and enter the following command:
./wso2esb-samples.sh -sn 1

    • Start the Apache Axis server

Next step is to start the Axis server where the SimpleStockQuote is deployed. To do this open a new terminal and navigate to ‘$CARBON_HOME/samples/axis2Server’ directory. Enter the command ./axis2server.sh.

    • Start the TcpMonitor

If you haven’t done already start the Tcp Monitor. Do this by opening a new terminal and browse to ‘$CARBON_HOME/bin’ and enter the command ./tcpmon.sh
This should start the Tcp Monitor tool:
Screen Shot 2013-03-14 at 21.09.12

    • Configure the TcpMonitor

We are going to listen to port 8281 and forward the incoming traffic to 8280 (that is where our ESB is running it’s proxy service).
Here is how to set this up in the Tcp Monitor:
Screen Shot 2013-03-14 at 21.25.42
After clicking the ‘Add’ button you see the TcpMonitor waiting for a connection:
Screen Shot 2013-03-14 at 21.26.06
So let’s send a message through it.

    • Run the Axis client

I made a small change to the statement as shown in the example page. Open a new terminal and run the following command from the directory ‘$CARBON_HOME/samples/axis2Client’: ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dprxurl=http://localhost:8281/ -Dmode=placeorder

    • Check the results

In the TCP Monitor we see that there is a line added to the TCP Monitor and in the lower part we see the incoming and outgoing request:
Screen Shot 2013-03-14 at 21.55.41

Here is the request sent by the Axis client:

<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/services/SimpleStockQuoteService</wsa:To>
      <wsa:ReplyTo>
         <wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
      </wsa:ReplyTo>
      <wsa:MessageID>urn:uuid:44ba7c6b-1836-4a62-8e40-814813a64022</wsa:MessageID>
      <wsa:Action>urn:placeOrder</wsa:Action>
   </soapenv:Header>
   <soapenv:Body>
      <m0:placeOrder xmlns:m0='http://services.samples'>
         <m0:order>
            <m0:price>154.76332953114107</m0:price>
            <m0:quantity>8769</m0:quantity>
            <m0:symbol>IBM</m0:symbol>
         </m0:order>
      </m0:placeOrder>
   </soapenv:Body>
</soapenv:Envelope>

The important thing to notice in the request is the following element in the header:

 <wsa:ReplyTo>
         <wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
      </wsa:ReplyTo>

With this element in the header we tell the we service we don’t expect a response. So what we get as a response is just the 202 response code as we can see in the TCP Monitor:

HTTP/1.1 202 Accepted
Content-Type: text/xml; charset=UTF-8
Server: Synapse-HttpComponents-NIO
Date: Thu, 14 Mar 2013 20:30:19 GMT
Transfer-Encoding: chunked

0

That completes this example, only a few more to go!
 

Reference: One way messaging with WSO2 ESB from our JCG partner Pascal Alma at the The Pragmatic Integrator blog.

Related Whitepaper:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

Leave a Reply


× one = 1



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.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books