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 Distributed transactions 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 "Distributed transactions" Watch "Distributed transactions" New topic

Distributed transactions

Sven Thor
Ranch Hand

Joined: Jan 31, 2004
Posts: 34
I am somewhat confused by the term distributed transactions.

Case 1: Your application consists of two EJBs running in separate VMs. There is only one database involved so the two phase protocol is not required. If the first EJB starts a transaction and then calls a method in the second EJB which uses transaction attribute Required, then the transaction context must be propagated between the EJBs.

Case 2: Your application consists of several EJBs all running in the same VM. Transactions running in the application might span different databases and/or message servers. This means that a transaction manager and the two phase protocol is needed for commit and rollback operations.

Which of these cases best fits the term "distributed transaction" ? I guess my question is what decides whether a transaction is distributed or not, the application itself being distributed (requiring RMI or something similar) or the fact that the application works with more than one resource manager (requiring use of the two phase protocol ?

I ask because I am not sure how to interpret statements such as this one about the embedded transaction manager in JBoss (from "Java Transaction Processing"): "...the current implementation does not support distributed transactions (although it is JTA compliant)...".

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

A distributed transaction is one which spans more than one transactional resource, so your second case is accurate. Distributed transactions use two-phase commit.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Distributed transactions
It's not a secret anymore!