Hi,

In our application, we have a dozen JMS queues and corresponding MDBs, running 
against an external ActiveMQ server.  All this is running reliably.

Recently, we had to add a new queue with the following requirement:  Some 
messages should not get processed concurrently. 

It looked like ActiveMQ Message Groups is built for this purpose so we added 
JMSXGroupID to messages that shouldn’t get processed concurrently  (Reference: 
http://activemq.apache.org/message-groups.html 
<http://activemq.apache.org/message-groups.html>)

However, this has not worked as we expected:  Even though the container is 
using a single MessageConsumer (which may be respecting our JMSXGroupID 
settings),  the onMessage method of multiple MDB instances are getting called 
concurrently for the same JMSXGroupID — and that is not acceptable per our 
requirement. 

Is there a way around this using MDBs?  E.g. some kind of TomEE or ActiveMQ 
setting?

If this is not possible using MDBs, what kind of architecture can be used to 
solve this problem?  (We thought about creating our own MessageConsumer in a 
Singleton and have it continuously poll this new queue but we are not excited 
about it.  This would not scale well and we don’t like the idea to manage 
transactions on our own.  Another idea we had was to use ReentrantLocks, but we 
realized that we have to release the lock after transaction is completed and we 
don’t have access to that from a stateless session bean.  That solution is 
messy in other fronts as well so again, we are not excited about it).

Any help will be greatly appreciated.

Thanks,

Ihsan. 

Reply via email to