File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Distributed transactions in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Distributed transactions in EJB" Watch "Distributed transactions in EJB" New topic

Distributed transactions in EJB

Joginder Raperia

Joined: Jan 06, 2004
Posts: 3
Sorry I put the subject wrong earleir ..
I am a little bit confused about the distributed transactions.I am not clear about the following things.
1. If I have a method in EJB for which I have defined the transaction-attribute as 'Required' and I am using different resources in that method
a)Sending message to some JMS destination (Queue)
b) updates to database
In this case if the driver I am using is not XA compliant ,what will happen.Will any exception be thrown or what?
2. Is it possible that the JMS Message sender and the receiving MDB (MessageDrivenBean) participate in the same trabsaction if we use XA driver?
Thanks in advance.
Goan Balchao
Ranch Hand

Joined: Mar 25, 2002
Posts: 93
I don't know the answer to the first part of your question. I would guess, that if the driver is not XA compliant, the behaviour is not fully determined by the psec -- I seem to remeber reading that somewhere (I am not sure though)
As to the second part,
"2. Is it possible that the JMS Message sender and the receiving MDB (MessageDrivenBean) participate in the same trabsaction if we use XA driver?"
No it is not possible for the JMS sender and the MDB to participate in the same transaction because, by it's nature MDB's are asynchronous. They cannot be in the same Tx, becuase from the spec " transaction context does not flow with a JMS message" .
The only scenarion would be : You could have the message receipt and the invocation of the MDB to be part of the same Tx, if you use CMT with "Required" Tx attribute. If you use BMT, the message receipt is not a part of the Tx.
Hope that helps. And please update the solution to your XA question, if you get it.

Hemant Kamat<br />SCJP2<br />SCWCD<br />SCBCD<br />SCEA-I
It is sorta covered in the JavaRanch Style Guide.
subject: Distributed transactions in EJB
It's not a secret anymore!