Thursday, April 24, 2008

Servicemix Queue filled - Queue size increased

I have been using servicemix since more then 1 year.As we have seen in urlier articles that servicemix uses ActiveMQ for Message queuing. The messages sent are filled in the Queue of destined component which will be fetched later on.

When we started using Servicemix, we faced a strange problem.After running for sometimes,our application stops processing messages.When we looked in the JMS Queue, we found that after certain period the messages in the queue are not removing.So new messages can't be processed.The Queue is full and we must restart the application to get rid of this.

Then we dig into the source code of servicemix and found how queue is given size.We increased the size as per our need and the problem was solved.

Basically when message processed by the component, it will be removed from its queue.But for some reason, if message not processed or not removed from the queue then further messages will be stored in the queue and processing stops.The application seems to be running but messages are not processed.

The class org.apache.servicemix.jbi.util.BoundedLinkedQueue contains the property capacity_
Constructor of this class contains the magic which initializes the capacity of queue size.

By default it is 1024.you can change it as per your need. I mean how much messages you think will be processed after every restart.

code:
public BoundedLinkedQueue() {
this(1024);
}
public BoundedLinkedQueue(int capacity) {
if (capacity <= 0)
throw new IllegalArgumentException();
capacity_ = capacity;
putSidePutPermits_ = capacity;
head_ = new LinkedNode(null);
last_ = head_;
}
I just simply changes the 1024 to bigger number like 1024*10 etc...

Try this.may be it can solve your problem also.

And others who know about servicemix and want to share their problems and tweaks are welcome.Put your comments here i will post it.

0 Comments: