Creating a simple proxy service in WSO2 ESB

Facebooktwittergoogle_plusredditpinterestlinkedinmail

 

Creating an integration flow in WSO2 ESB is really a simple concept. Let’s dive into implementing a simple JMS based use case on WSO2 ESB.

The difference:

The key difference that any integration developer could find with WSO2 ESB is proxy service model. The endpoints are directly exposed in other integration platforms like Apache Camel, Mule ESB, etc.. In WSO2 ESB everything starts with a proxy, the entry to any synapse flow will be a proxy. Other way we can say that the mediations are wrapped by a proxy layer.

Creating a simple flow based on JMS:

The diagram below shows the simple use case which we are going to deploy in WSO2 ESB.

Figure 1: Use case

Note : If the proxy entry is a JMS queue then the input queue name and the proxy service name should be same.

Step 1:

Start the WSO2 ESB using the wso2server.bat/wso2server.sh from WSO2ESB_HOME\bin

Step 2:

Access the WSO2 ESB Management Console at https://localhost:9443/carbon

Step 3:

Start the ActiveMQ broker using activemq.bat/activemq.sh from ACTIVEMQ_HOME\bin

Step 4:

Access the Active MQ monitoring console to monitor the queue at http://localhost:8161/admin

Step 5:

There are two ways to create a proxy service.

  1. Using the WSO2 web console located at https://localhost:9443/carbon -> Services -> Add -> Proxy Service – This will be a UI based configuration
  2. Direct XML deployment. Create the proxy service xml and paste it to ESB_HOME\repository\deployment\server\synapse-configs\default\proxy-services for deployment.

Let’s take the second option. By the way after deploying the proxy service you should be able to trace the UI based configuration from the WSO2 web console. That’s another cool way of learning proxy configuration in WSO2 ESB.

Create an xml file with the following configuration. ( EntryQueue.xml )

<proxy xmlns="http://ws.apache.org/ns/synapse" name="EntryQueue"

transports="https,http,jms"statistics="disable"trace="disable"

startOnLoad="true">

<target>

<inSequence>

<send>

<endpoint>

<address

uri="jms:/ExitQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616"/>

</endpoint>

</send>

</inSequence>

<outSequence>

<drop/>

</outSequence>

<faultSequence/>

</target>

<parametername="transport.jms.ContentType">

<rules>

<jmsProperty>contentType</jmsProperty>

<default>text/plain</default>

</rules>

</parameter>

<description></description>

</proxy>

 

Note : The xml file name and the proxy service name should be same.

Step 6:

Deploy the proxy service by pasting the xml file at ESB_HOME\repository\deployment\server\synapse-configs\default\proxy-services ( ESB_Home is the home directory of WSO2 ESB)

Step 7:

Verify the successful deployment of the proxy service from the WSO2 web console. ‘EntryQueue’ proxy will be listed in Manage -> Services -> List

 

Figure 2: Deployed proxy services

Step 8:

Let’s test now by sending some sample messages to the EntryQueue. You can use the ActiveMQ web client for sending the messages.

  1. Queues can be monitored at http://localhost:8161/admin/queues.jsp
  2. Messaging client is located at http://localhost:8161/admin/send.jsp

Let’s send 10 messages to ‘EntryQueue’. After few second ‘ExitQueue’ will be created and the messages from ‘EntryQueue’ will be delegated to ‘ExitQueue’. You can verify this using the queue monitoring console. If you are familiar, you can use JConsole.

Figure 3: Queue monitoring

 

Hope it was helpful to start working on WSO2 ESB with a simple use case. Happy Integration !!

 

 

 

Facebooktwittergoogle_plusredditpinterestlinkedinmail
Gnanaguru Sattanathan

Gnanaguru Sattanathan

I am a Integration developer and a open source enthusiast. My areas of interest includes Enterprise messaging & SOA. Twitter: @tallguru

You may also like...

1 Response

  1. Kristjan Mustkivi says:

    Finally a solution that worked! Thank you!

    WSO2 ESB official documentation seems to be lengthy and thorough but really lacks in many aspects. At least for WSO2 newbie like myself. So far most of the useful and helpful information has come from personal blogs instead of the official docs.

    I was having trouble getting the scenario to work with WSO2 ESB 4.8.1 and AMQ 5.12.0.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>