I need to be able to use Bean managed txns(BMT) to acknowledge message receipt in a MDB. I am using Weblogic Server 7.0 which says that in the case of MDBs which use BMT, message acknowledgement is done outside the beans txn context. The reason I need to do this is to be able to take care of situations wherein if the MDB fails for some reason after receiving the message and before having had a chance to process the message. If I use BMT with my MDB, there is no way I can indicate to the the JMS provider to resend the message when the MDB fails. Any ideas on how to design for this?
Why not use CMT? [ April 07, 2003: Message edited by: Chris Mathews ]
Joined: Jul 18, 2001
Let me elaborate... This is a problem with any Application Server when using MDBs and BMT. The JMS Message must be dequeued before the MDB gets a chance to start its transaction in onMessage() and therefore the message consumption takes place outside the context of the transaction. This is actally part of the EJB Specification and is non-negotiable. For this reason I can think of zero cases where I would want to use BMT with an MDB. If you need the additional control of the transaction then create a Session Bean using BMT which you can call from your MDB.
Joined: Apr 07, 2003
The reason I need to use BMT in place of CMT is because of the architecture of my application. Here is how it works: The MDB receives a message from the Topic/Queue and then calls another bean or business method which does a "while(TRUE) loop" on database events. In effect, the onMessage() call never completes. Since the onMessage() method never completes, if I were to use CMT for the MDB, the txn between the JMS provider and the container hosting the MDB would be open for a very long time and never end unless we forced the database event to end the while(TRUE) loop. I was not very comfortable with using long running txns and was attempting at using BMT to solve the problem. Any suggestions on how I could design for this kind of scenario?