Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Distributed transactions

 
Sven Thor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)...".

Br,
ST
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A distributed transaction is one which spans more than one transactional resource, so your second case is accurate. Distributed transactions use two-phase commit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic