Monday, September 22, 2008

ServiceMix 3.2.1 with ActiveMQ 4.1 Gotchas

We have using servicemix for last year or so. So far the results have been mixed. The most important downside is being activemq. One of my initial draw to servicemix was activemq and its seda flow support. ActiveMQ has been mediocre at best in our situation. I would list some of the gotchas and how we came across it.

When you have mulitple fast publishers and slow subscribers activemq sometimes freezes up. This becomes all the more common if a subscriber did not close the connection gracefully. The reason is activemq's internal memory cache that stores the messages untile a subscriber has successfuly received the messaged. The memory cache is set to 20MB by default. If the memory cache runs out of space, the broker freezes up as all the threads wait on the cache to release some space, which does not happen in case of faulty subscriber.

You can increase the cache size by setting activemq' usagemessage size in bytes as follows.


<amq:broker id="hub" useShutdownHook="false" useJmx="false" persistent="false" brokerName="hub" >
....

<!-- set limit to 200mb -->
<amq:memoryManager >
<amq:usageManager limit="209657600"/>
</amq:memoryManager>

</amq:broker>

2 comments:

James Strachan said...

BTW this tends to be a problem with many message brokers - dealing with slow consumers. There are various solutions to the problem.

FWIW this is mostly a solved problem in ActiveMQ 5.x now as we support better memory cursors...

http://activemq.apache.org/message-cursors.html

along with disk spooling to avoid RAM exhaustion

Suresh Avadhanula said...

Thanks for the comment. I will definitely look into it. I am not sure if I can plugin activemq 5.1 instead of activemq 4.1. I faced issues when we went from servicemix-incubating with activemq 5.1 acting as broker.