|
From: <jas...@ma...> - 2004-10-27 09:23:19
|
This has been an ongoing area of research for some time - how best to do JMS consumption from inside Spring. After scratching my head for a while over the best way to do this; I figured, JCA is the answer, since it takes care of all the thorny issues behind doing proper consumer based JMS pooling and transaction handling, which is way more complex than you might imagine. The only downside of this approach is that folks often think JCA is really complex & fat & depends on a J2EE container which is not true. As part of the ActiveMQ project we've written a small, Spring based & easily embedded JCA container. Its just a few classes and is easy to use on any project, just depending on Spring and the JCA APIs. http://activemq.codehaus.org/JCA+Container So we can now have all the features of MDB such as efficient JMS pooling, hooks to work with all the major JMS providers via their JCA Resource Adapters (*), proper transaction handling and pooling of message listeners - but all from within Spring. We get the added benefit that we get to use Spring's Dependency Injection to configure the message listeners properly - plus we can easily perform the dynamic creation of new subscriptions easily at runtime, rather than having to rely on a fixed & rigid XML deployment configuration like EJB. So now we've 'message driven pojos' in Spring! :) To give you an idea of how simple it is, here's a sample... http://cvs.activemq.codehaus.org/viewrep/activemq/activemq/modules/ container/src/test/org/codehaus/activemq/jca/spring.xml?r=HEAD There's more detailed documentation on the above page if you need it. (*) to help work with other JMS providers which don't yet provide a JCA ResourceAdapter, which they really should if they want to integrate well with other J2EE containers, we could enhance ActiveMQ's ResourceAdapter to work with foreign JMS providers. James ------- http://radio.weblogs.com/0112098/ |