You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by JR <jl...@gmail.com> on 2009/12/17 15:45:15 UTC

Using JTA and Jackrabbit

The project I'm working on is using Jackrabbit 1.4 for content storage. The
project is mostly implemented, but we ran into a database issue that caused
a few saves to the repository to fail in the middle of committing the
changes. This left the repository in an inconsistent state and was bad all
around. We'd like to avoid this in the future and I believe the way to do
that is through transactions. The FAQ [1] mentions that Jackrabbit supports
the use of JTA and that there are examples of how to do this on the mailing
list announcement, but I haven't been able to find that announcement or a
simple example anywhere. Any help would be appreciated. Thanks in advance!

Jared

[1]
http://jackrabbit.apache.org/frequently-asked-questions.html#FrequentlyAskedQuestions-HowdoIusetransactionswithJCR
?

Re: Using JTA and Jackrabbit

Posted by Ian Boston <ie...@tfd.co.uk>.
The standard Jackrabbit Session is an XASession which implements an XAResource which you can attach to Global transaction.

eg
    XASession xasession = (XASession) session;
    Transaction transaction = transactionManager.getTransaction();
      if (transaction != null) {
        transaction.enlistResource(xasession.getXAResource());
      }

from that point on the XASession will respond to the transaction lifecycle of the transaction.
IIRC, nothing is visible to other threads, the shared item manager or the persistence manager until transaction.commit() happens, even if sesison.save() happend before then.

HTH
Ian

On 17 Dec 2009, at 14:45, JR wrote:

> The project I'm working on is using Jackrabbit 1.4 for content storage. The
> project is mostly implemented, but we ran into a database issue that caused
> a few saves to the repository to fail in the middle of committing the
> changes. This left the repository in an inconsistent state and was bad all
> around. We'd like to avoid this in the future and I believe the way to do
> that is through transactions. The FAQ [1] mentions that Jackrabbit supports
> the use of JTA and that there are examples of how to do this on the mailing
> list announcement, but I haven't been able to find that announcement or a
> simple example anywhere. Any help would be appreciated. Thanks in advance!
> 
> Jared
> 
> [1]
> http://jackrabbit.apache.org/frequently-asked-questions.html#FrequentlyAskedQuestions-HowdoIusetransactionswithJCR
> ?