File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Transactions and MDBs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Transactions and MDBs" Watch "Transactions and MDBs" New topic

Transactions and MDBs

Nidhi Juneja

Joined: Oct 07, 2002
Posts: 27
Hi all,
Need ur inputs about using Container Managed Transaction with MDBs.

I have a MDB which uses some helper classes and a Stateless Session Bean for performing its business logic. I am using Container Managed Transaction for the MDB. Do I need to seperately specify the transaction attribute for the Stateless Session Bean this MDB uses or will it be automatically included in the MDB's transaction.
According to Ed Roman:
If you use Conatiner Managed Transaction, MDB will read off the message in the same transaction as it performs its business logic.

Also how can I test that transactions are working as expected.

Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
If you want the Stateless Session Bean's methods to run inside the transaction started by the MDB, you should use "Required" as a <trans-attribute>.
For example, if inside onMessage() you are calling a session bean named ProcessSession, inside the deployment descriptor for this session bean you should have:
<method-name>methodName or '*' for all methods</method-name>
Inside Ed Roman's "Mastering EJB 2nd edition" you can find a pretty detailed explanation about Container Managed Transaction.
cheers I'm walking the path...
I agree. Here's the link:
subject: Transactions and MDBs
It's not a secret anymore!