activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jongraf <>
Subject Processing multiple messages in the queue at once
Date Thu, 07 Jan 2010 21:22:51 GMT

Hello fellow developers,

I find myself in the midst of the age-old dilemma of needing to provide
scalable code where our load tests currently indicate that the code is
otherwise.  I am coding a message-driven POJO.  Originally I implemented the
queue using the Spring DefaultMessageListenerContainer and discovered that
this is invoked upon every message received (hence, "listener").  Because
our load tests are bombarding our server, the performance benchmarks were
not great. 

I figured that if I write my own timer instead of a listener, performance
would improve.  I coded a Quartz-triggered method that calls iterates over
jmsTemplate.recieve() for a given batch size.  The messages are sent in one
batch to a remote REST service.

This has not improved performance.  After doing some research, I found that
a caveat of the jmsTemplate is that you do not really want to be calling
jmsTemplate.receive() because it opens a new connection & session each time. 
This is bad.

Here is where I need your help:
1) Is there not a way to use the Spring DefaultMessageListenerContainer to
rid the queue of many messages at once?  My confusion lies in the
implementation of the onMessage() method where I believe only one message is
available at a time. 

2) Is there a way I can set a timer so that queue is only purged when I want
it to be?  Perhaps this goes against the MDP pattern but I would really love
some education here.

The forums seem to point to JMS Transactions as a solution for batching
objects from a JMS queue.   I am also unfamiliar with how to tie this into
the DefaultMessageListenerContainer.

Any help or direction you could provide would be most appreciated.

Thank you,

Developer from NYC
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message