Wednesday, February 22, 2012

WSO2 MB - Samples : SQS SOAP Client Sample

Many users experiencing problems when testing this sample.



Here i am going to mention few simple steps to execute this sample.

1. Download WSO2MB 1.0.2 pack from http://wso2.org/downloads/message-broker

2. Extract and start the product.

3. Log in to the admin console of MB with credentials admin/admin



4. Navigate to the WSDL2Java tool which can be found in "Tools" left menu



5. Copy and paste the url of sqs wsdl to the provided test box in the "uri" option

6. Press generate button which can be found in the bottom of that page and it will give you the
zip file of generated source pack and save it.

7. Extract the source pack to your project folder. Once you extracted it, you can see a structure like :
.
|-- build.xml
|-- pom.xml
`-- src
`-- com
`-- amazonaws
`-- queue
`-- doc
`-- _2009_02_01
|-- MessageQueueCallbackHandler.java
|-- MessageQueueStub.java
|-- QueueServiceCallbackHandler.java
`-- QueueServiceStub.java


8. Go inside the project folder where you can find the above pom.xml file in the command line. Create the idea project by typing "mvn idea:idea".

9. Open the created project with IDEA

10. Add the SQSClient class to the project.

11. Change the "accessKey" and the "secretAccessKey" to the keys which can be found at "Home > Manage> Message Boxes(SQS)> Access Keys" of wso2mb server.


12.Build the project and execute the sqs client




NOTE:

Possible errors to be occurred when building the project

"cannot find symbol method createOMElement(org.apache.axiom.om.OMDataSource,javax.xml.namespace.QName)"

This is due to version mismatch of the axiom. Valid version of all axiom libraries is the version specified in the pom.xml

eg: 1.2.11.wso2v1

But where there are axiom libraries which is different from the above version, it gives above error.

You need to remove that version mismatching library from your class path .
Eg: axiom-api-1.2.7.jar

With this way you can get rid of this problem.

Thursday, February 16, 2012

Allowing a port from firewall in ubuntu

Lets say the port we need to make open from firewall is "2181"

$sudo ufw allow 2181

Wednesday, February 15, 2012

ZooKeeper Increase maximum number of connections

When using zookeeper you may get the following exception:

org.apache.zookeeper.KeeperException$ConnectionLossException:
KeeperErrorCode = ConnectionLoss for /foo.XXXXXXXX
at org.apache.zookeeper.KeeperException.create(KeeperException.java

At the same time if you view the log of zookeeper you will see the the following warning :

WARN org.apache.zookeeper.server.NIOServerCnxn: Too many connections from /127.0.0.1 - max is 10

This is due to the default maximum number of connections configured in zookeeper.

You can overcome this by setting up the maximum number of connections in zoo keeper configuration file.(conf/zoo.cfg)

Add following entry to zoo.cfg file and restart zooKeeper. It will set maximum number of connections to 30.

"maxClientCnxns=30"

Killing multiple java processes at once

There are situations we need to kill multiple java processes at once. We can do it by killing all java processes. But there may be requirements to kill some filtered out java processes.

Lets say i have some processes which are running with details "OnceInOrderLoadTest.jar". I can kill all processes running with that details as bellow.


ps ax | grep OnceInOrderLoadTest.jar |grep -v grep | awk '{print $1}'| xargs kill -9

Wednesday, February 8, 2012

SQS Client for Stratos Live

It is a great advantage , if we can test message box feature of wso2 message broker in stratos live environment since it takes some time to set up product locally and test. Here i am going to describe how we can use a java client to invoke message box feature which acts as a message store of Wso2 Message broker in stratos live environment.

We can find the sample on creating "SQS SOAP Client" in here. This sample is specifically written for standalone product testing.

For stratos testing there are only few things need to be changed in this sample.

As described in the above sample as the first step you need to generate the code for the SQS wsdl.

For that you have multiple ways,
1. Use Axis2 wsdl2java tool for code generation
You can find samples on how to do that here.

2. Use wsdl2java feature of any of the wso2 products and generate the code from that.

Once you generate the code with using one of the above two methods, you can create a project using those source files.


If it is not automatically added the required libraries to the class path of your project, you need to add the libraries to the class path.

You can find all the required libraries for this source code in Message Broker product.
what you need to do is;

1. Extract wso2mb-1.0.2.zip
2. go to wso2mb-1.0.2/bin folder and run "ant" command
3. This will create a lib folder in "wso2mb-1.0.2/repository/" folder
4. You can add this lib folder to your class path

Once you have created the project successfully, you can use the same client for invoking Stratos Live Message Broker. How ever before invoking the client, you need to do some changes in that client code.

You need to change following constant of that client;
Eg: For the tenant foo.com , EPR will be

public static final String EPR = "http://messaging.stratoslive.wso2.com/services/a/foo.com/QueueService";

Apart from that you need to get the "accessKey" and the "secretAccessKey" after log in to the Message Broker service.

With changing those constants , you will be able to use the message box feature of Stratos Message Broker Service successfully.