Month: September 2011

Servicemix Tweaks to improve App Performance


The story behind this post

I have been using the Servicemix ESB ( Version 3.3.1 ) for quite some time for an Integration project. In quick words, this is how the App Architecture looks like.

The ActiveMq component embedded inside the SMX recieves JMS messages from an external client. Now, i have a Camel processor listening to the ActiveMQ broker ( ie the queues set up on the broker ). When a message arrives in of the queues, the camel PROCESSOR picks it up and forwards it to a BPEL process being executed by the ODE BPEL Engine ( Version 1.3.3 ). Within the BPEL process, it calls webservices hosted outside the ESB environment through an HTTP Provider Binding component.

The Problem

When the load to the App increases ( ie high number of concurrent requests ) , the BPEL engine fails to handle some of the requests passed to it and it inevitably throws the No Such Channel Exception eventually hangs.

The Solution

After a few days of frantic searching and posts on Apache Servicemix and ODE messageboards, this is what i found out.

The reason why the BPEL Engine stops responding to requests is because of the following reasons

1. Servicemix Thread Freeze :  ie there are too less number of threads within the servicemix to process these request.

Solution : This can be solved by re configuring the Threadconfiguration specified in the servicemix.properties in the conf folder in Servicemix. After reconfiguring , my configuration looks like this

servicemix.corePoolSize    = 100
servicemix.maximumPoolSize = 200
servicemix.queueSize       = 10

The corePoolSize specifies the number of initial threads available inside Servicemix. The quesize specifies the number of requests which will be queued before starting to spawn new threads up till a maximum limit as specified by the maximumPoolSize.

Find more about the Servicemix Thread Pool Executor (TPE ) here

2. Not enough threads within the BPEL Engine to handle the different process activities.

Solution : This can be solved by reconfiguring the corepoolsize property mentioned in the ode-jbi.properties file of the ode bpel engine. The ode engine comes inazipped format, so u will have to unzip the file, edit the ode-jbi.properties file and then re-zip and redeploy it again.

Find below, the configuration that i use

ode-jbi.threads.pool.size=20

The Story Now

The BPEL Engine has stopped hanging ie it doesn’t miss any requests anymore, but on the flip side the NoSuchChannelException continues to flood the Servicemix logs. Maybe, there is more to it than what meets the eye.

Hoping to solve that and get it posted here at the earliest.

Cheers,

The Nonsense Blogger !!

Advertisements

Zip command in Ubuntu


 

Zipping a File

Format : zip <filename.zip> dir1 dir2…..

Example : zip abc.zip test1/ test2/

This creates a zip file abc.zip with the contents of  folders test1 and test2

 

Unzipping a File

Format : unzip <filename.zip>

Example : unzip abc.zip

This unzips the contents of abc.zip to the current directory location

 

Unzipping a File to a specific folder

Format : unzip <filename.zip> -d dirname/

Example : unzip abc.zip -d unzip_dir/

This creates a folder unzip_dir and then unzips the contents of abc.zip to that folder.

 

Regards,

The NonsenseBlogger

Back To Basics : Polymorphism in Java


What is Polymorphism

Polymorphism is the idea of invoking  different methods having the same name, but different implementations.

The following scenario explains it best. I have class called MyMathClass. Now, i need a method which will add two integers. This is what i do.

Class MyMathClass {

public int add(int a,int b) {

return (a+b);

}

}

Job well done. You create an instance of MyMathClass and use it to invoke the add  method which returns you the sum of two inetegers passed to it. That’s neat. 🙂 🙂

But what do you do if you want to expose a method which adds 3 integers or for that matter n  integers passed to it. Imagine a situation where there is no concept called polymorphism, you will have to create different implementations of the same add method with different names. Assume that you need to package and expose this MyMathClass as an API. Now, the user’s of this API will need to know the names of the different methods which performs the same functionality – add. Now that does not look very neat. 😦 😦

This is where polymorphism makes its entry.  Polymorphism enables Class instances ( objects ) to refer to different method implementations having the same name. This is possible by varying the method signature ( the order or the number of parameters taken in as input by the method ). Find below, how MyMathClass gets transformed after polymorphism.

Class MyMathClass {

/* Method to add two integers */

public int add(int a,int b) {

return (a+b);

}

/* Method to add 3 integers */

public int add(int a,int b,int c) {

return (a+b+c);

}

/*Method to add n integers */

public int add(int a[],int n) {

int sum=0;

for(int i=0;i<n;i++){

sum = sum+a[i];

}

}

}

public MyMathClassDemo {

public static void main() {

MyMathClass myMathClassObject = new MyMathClass();

int sum = myMathClassObject.add(2,3); // Calls the add method for adding the two integers

sum = myMathClassObject.add(2,3,4); // Calls the add method for adding three integers

int a[] = new int[] {1,2,3,4,5};

sum = myMathClassObject.add(a,5); // Calls the method to add n integers

}

}

Now that’s polymorphism for you. Polymorphism itself is of two types – static and dynamic. The one explained above is static polymorphism. ie the binding between the instance variable ( in this case, myMathClassObject ) and the method calls is done during the code compile time. Hence the name static polymorphism.

There is another type of polymorphism – dynamic polymorphism where the binding is done during runtime or dynamically. But, that’s for a different post. Between, Hope this helps.

Cheers,

The Nonsense Blogger