2010/12/08
8 Dec, 2010

WSO2 ESB and Apache Qpid Setup Guide

  • Lahiru Gunathilake
  • Senior Software Engineer - WSO2

   

Applies To:   WSO2 ESB 3.0.0/3.0.1 with Apache Qpid 0.6 Release

1. Download Apache Qpid from here https://www.apache.org/dist/qpid/0.6/qpid-java-0.6.tar.gz. Extract and open the QPID_HOME/etc/config.xml change enable ssl false as below.

<management>
<enabled>true</enabled>
<jmxport>8999</jmxport>
<ssl>
<enabled>false</enabled>
<!-- Update below path to your keystore location, eg ${conf}/qpid.keystore -->
<keyStorePath>${prefix}/../test-profiles/test_resources/ssl/keystore.jks</keyStorePath>
<keyStorePassword>password</keyStorePassword>
</ssl>
</management>
<port>5673</port>
<sslport>8673</sslport> 

Note: If you are going to use Apache Qpid C++ broker, download the broker from https://www.apache.org/dist/qpid/0.6/qpid-cpp-0.6.tar.gz, refer the INSTALL file, build it in your platform and start Qpid Java broker with the following command - > QPID_HOME/sbin/qpidd --auth no

 2. If you want to use Apache Qpid in a clustering mode and extract another Apache Qpid instance, do step 1 and edit QPID_HOME/etc/config.xml and change the ports configuration by editing port and sslport elements.

3. Start Apache Qpid by running QPID_HOME/bin/qpid-server. If you are using a cluster start all the instances.

 

Configuring WSO2 ESB instance that forwards incoming messages to Apache Qpid instance

1. Create a server.properties file in CARBON_HOME/repository/conf/ directory and add the following entries to the properties file.

connectionfactory.qpidConnectionfactory=amqp://guest:guest@clientid/test?brokerlist='tcp://10.3.24.99:5672'
destination.directQueue=direct://amq.direct//ServiceName
destination.replyQueue =direct://amq.direct//ServiceNameReply

In this configuration 10.3.24.99 is the IP address of the machine which Apache Qpid is running and qpidConnectionfactory is a reference we are using for our reference in axis2.xml.

If you are using Apache Qpid in a cluster, create another properties file and define the same configuration with a different file name. Let's assume your secondary configuration file is server1.properties.

2. Now open the CARBON_HOME/repository/conf/axis2.xml and add the following entry

 

Adding transportRecievers

 

<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="default" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.apache.qpid.jndi.PropertiesFileInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">/home/wso2/WSO2_SETUP1/wso2esb-3.0.0/repository/conf/server.properties</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">qpidConnectionfactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter>
<parameter name="slave" locked="false">
<parameter name="java.naming.factory.initial"
locked="false">org.apache.qpid.jndi.PropertiesFileInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">/home/wso2/WSO2_SETUP1/wso2esb-3.0.0/repository/conf/server1.properties</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">qpidConnectionfactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
</transportReceiver>
Change the java.naming.privider.url element according to your setup. 

Adding transportSenders

<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>

3. If you need only one Apache Qpid instance, remove the second parameter list and keep the default configuration (parameter set with name="default") and note the name of the second parameter set is "slave" We need to use that configuration to be added in to synapse configuration when we configure failover endpoints.

4. Copy following jars in to CARBON_HOME/repository/components/lib directory and download the merged jar from the given location. The rest of the jars can be found in QPID_HOME/lib directory.
qpid-common-merged.jar https://people.apache.org/~lahiru/qpid-common-merged-0.6.jar
qpid-client-0.6.jar
slf4j-api-1.4.0.jar
5. Start the WSO2 ESB instance by running CARBON_HOME/bin/wso2server.sh or .bat file, now it will connect to the Apache Qpid instance running successfully.

 

Configuring ESB instance which picks incoming messages from Apache Qpid and forward them to the actual service

Perform all the steps from step 1-5 in the WSO2 ESB in main setup where we call the MemberVerification service directly. This ESB instance has to be configured with Apache Qpid to pick messages from the queues and send the request to the actual service, and once the response comes back, put the reponse in to the reply queue defined in server.properties file.

But in the server.properties file you do not need to add a replyQueue in the configuration. 'server.properties' file looks like this:

connectionfactory.qpidConnectionfactory=amqp://guest:guest@clientid/test?brokerlist='tcp://10.3.24.99:5672'

Assume 10.3.24.99 is the IP address of the machine where you run the Apache Qpid instance.

After you start WSO2 ESB, there will be Queues created in Apache Qpid for all the proxy services you have created in your Synapse configuration, if a message received to any of those queues, ESB will consume those messages and hit the In-Sequence of appropriate proxy service.

 

Author: Lahiru Gunathilake, Senior Software Engineer, WSO2 Inc

 

About Author

  • Lahiru Gunathilake
  • Senior Software Engineer
  • WSO2 Inc.