Tuesday, December 2, 2008

Enabling JMS transport for Axis2 services

This post explains how you could enable JMS transport for Axis2 services deployed on WSAS.

WSO2 WSAS is an enterprise ready Web services engine powered by Apache Axis2.

It is a lightweight, high performing platform for Service Oriented Architectures, enabling business logic and applications. Bringing together a number of Apache Web services projects, WSO2 WSAS provides a secure, transactional and reliable runtime for deploying and managing Web services

Once you start WSAS with [WSAS_HOME]\bin\startup.bat and hit the url https://localhost:9443 you can login with admin/admin.

Click the menu item 'services' and you'll find the set of available services.

Click on the 'echo' service and then the 'Manage Transports' - you can find that only http and https transports are available.

Let's see how we can configure JMS for the 'echo' service.

You can find axis2.xml inside [WSAS_HOME]\conf - edit it to uncomment the following.

<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory">
<parameter name="java.naming.factory.initial">
<parameter name="java.naming.provider.url">
<parameter name="transport.jms.ConnectionFactoryJNDIName">

<parameter name="myQueueConnectionFactory">
<parameter name="java.naming.factory.initial">
<parameter name="java.naming.provider.url">
<parameter name="transport.jms.ConnectionFactoryJNDIName">

<parameter name="default">
<parameter name="java.naming.factory.initial">
<parameter name="java.naming.provider.url">
<parameter name="transport.jms.ConnectionFactoryJNDIName">

<transportSender name="jms"
The above configuration defines three connection factories.

The JMS transport receiver configuration allows you to define the default connection factory (named as "default") for use by Axis2 services using the JMS transport. This connection factory would be used by any service which does not explicitly specify a connection factory name in its services.xml.

In case your service needs a different connection factory,other than the 'default' one - that needs to be mentioned in the services.xml.

<parameter name="transport.jms.ConnectionFactory" locked="true">myTopicConnectionFactory</parameter>
Now you need to run a message broker. You can download ActiveMQ 5.2 from here.

Copy the file activemq-all-5.2.0.jar from [ACTIVEMQ_HOME] to [WSAS_HOME]\lib.

All set - now restart the WSAS.

If you view transports available for 'echo' service through WSAS admin console [as you did previously], you'll find JMS is now available.

Also in the 'echo' service page you may notice that there are three endpoints available under 'Endpoint References' - what we'll be using for the 'echo' service client is the 'jms' endpoint.

One thing to notice here is a service on an Axis2 instance is deployed on all started transports by default, unless a list of transports are specified in its services.xml.

In case your service only to be deployed on JMS, you should specify it in the services.xml

All set - let's move to the client.

Make sure you have the actievemq-all-5.2.0.jar in the client classpath and jms transport being enabled in client.axis2.xml.

package org.apache.ws.axis2;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;

public class Client {

* @param args
* @throws AxisFault
public static void main(String[] args) throws AxisFault {

ConfigurationContext context = null;
ServiceClient client = null;
Options options = null;
OMElement response = null;

context = ConfigurationContextFactory.createConfigurationContextFromFileSystem("repo",
client = new ServiceClient(context, null);
options = new Options();
.setTo(new EndpointReference(
+ "&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ "&java.naming.provider.url=tcp://localhost:61616"));

response = client.sendReceive(getPayload("hi"));
System.out.println(response.getFirstChildWithName(new QName("return")).getText());

private static OMElement getPayload(String value) {
OMFactory factory = null;
OMNamespace ns = null;
OMElement elem = null;
OMElement childElem = null;

factory = OMAbstractFactory.getOMFactory();
ns = factory.createOMNamespace("http://echo.services.wsas.wso2.org", "ns1");
elem = factory.createOMElement("echoString", ns);
childElem = factory.createOMElement("param0", null);
return elem;



Jissma said...

for WSAS 3.0.1 and activeMq 5.2

in lib/extensions

crystal said...

Thank you so much!!polo shirt men'ssweate,Burberry Polo Shirts lacoste sweater, ralph lauren Columbia Jackets,ski clothing. Free Shipping, PayPal Payment. Enjoy your shopping experience on mensclothingus.com.You can find the father who desire fashionable, intellectual mens clothing simultaneously.

crystal said...

Awesome!!!Best wishes for you !!cheap polo shirts is the father of the summer should be prepared to most commonly used item, it has both style and shape of Ralph Lauren Polo, and vest with a random function polo ralph lauren, so that in the short-sleeved apply to both on many occasions, the pink and black color men's polo shirts brought into effect, lightweight cotton, linen texture to demonstrate masculine temperament and sense of fashion exhaustively.

venus said...

God bless you!I really agree with your opinions.Also,there are some new fashion things here,gillette razor blades.gillette mach3 razor bladesfor men.As for ladies,gillette venus razor blades must the best gift for you in summer,gillette fusion blades are all the best choice for you.

crystal said...

Perfect!!You are a outstanding person!Have you ever wore chaussures puma,Here are the most popular puma CAT,Puma shoes store gives some preview of puma speed cat,and casual but no sweat puma basket.

crystal said...

Do not mean bad.Thank you so much!I just want to show some fashion things to all of you.I like puma speed, puma femmes and other puma shoes. These puma sport items are at store recently and available for anyone.

venus said...

Fantastic!God bless you!Meanwhile,you can visit my China Wholesale,we have the highest quality but the lowest price fashion products wholesale from China.Here are the most popular China Wholesale productsfor all of you.You can visit http://chinaclothes.net.Also the polo clothing is a great choice for you.
Puma sport
polo shirts
polo shirts
gillette razor blades
Queen--ugg boots
original polo clothing

jim smith said...

Linen texture to demonstrate masculine temperament and sense of fashion exhaustively.
Transmissions Hollywood FL

raybanoutlet001 said...

louboutin shoes
nike huarache
yeezy shoes
mont blanc outlet
ed hardy uk
michael kors handbags
ugg boots
oakley sunglasses
ugg boots
coach outlet online

1111141414 said...

nike kyrie 3
basketball shoes
nike air force
yeezy boost 350
stephen curry shoes
tory burch shoes
adidas ultra boost 3.0
adidas tubular x
links of london
christian louboutin shoes