From: gk on
Here I have a query in simple JTA Transaction . I am reading from
the book "Beginning Spring Framework 2" By Thomas Van De Velde,
Bruce Snyder, Christian Dupuis, Sing Li, Anne Horton .

There is one section where I'm confused . I have written my query
along side the code. Please have a look at this book excerpt . This
is a google book graphic print .

http://i218.photobucket.com/albums/cc298/curseofgoldendragon/programmatictransaction.png

Could you please clear this part.

Regards.

From: Owen Jacobson on
On 2010-08-13 08:37:38 -0400, gk said:

> Here I have a query in simple JTA Transaction . I am reading from
> the book "Beginning Spring Framework 2" By Thomas Van De Velde,
> Bruce Snyder, Christian Dupuis, Sing Li, Anne Horton .
>
> There is one section where I'm confused . I have written my query
> along side the code. Please have a look at this book excerpt . This
> is a google book graphic print .

Can you please stop doing this? Transcribing the code in question will
make it much easier for people to answer your questions. Since you're
getting answers for free, it's in your interest to make it easy.

As for your question: when multiple transactional resources are in use
in a single JTA transaction (for example, when you're working with a
database and a message broker), JTA uses something called XA* to
coordinate commits and rollbacks. XA specifies a two-phase commit
mechanism that ensures that all transactional resources will commit a
transaction ("prepare" phase) before actually committing the
transaction ("commit" phase).

As a result, the resources you're using in your transaction must
support XA transactions. Most transaction-capable systems do support it
(XA is widely used in enterprise apps), but there are a few that don't.
Attempting to use non-XA resources in an XA transaction will fail early
(and abort the transaction) rather than risking inconsistencies. Read
the documentation for your transactional services (JDBC drivers,
message brokers, JCA connectors, and so on) for information on how to
set them up for XA transactions.

Some JTA implementations support adding a single non-XA resource into
an XA transaction; there is an implementation for this that is
transactionally safe provided no heuristic recovery has to happen. Read
the manual for your transaction manager (usually, part of your EE
container) for details.

-o

* http://en.wikipedia.org/wiki/X/Open_XA