You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Peter Henzler <ph...@scodi.ch> on 2009/05/27 11:31:30 UTC

How to handle XA Transactions?

Hi

After searching for days the web for information about how to work with XA (Distributed Transactions) I am more confused than before.

I want to use Jackrabbit in a spring framework without an application server.
I want to handle transactions through spring annotations and JTA Transaction API.

Is it true, that the Jackrabbit transaction support can only work with UserTransactions and can't work with distributed transactions?
Is it true, that I can only get Jackrabbit working together with XA Transactions if I use the Jackrabbit JCA interface?
Do you know any other working solutions (other than the  Jencks) for using the Jackrabbit JCA without an application server in the background?

If I am using the Jackrabbit Datastore and Persistence configured with an XA JDBC-Driver, do I really need Transactions in Jackrabbit. Wouldn't the XA JDBC-Driver work in a 2phase commit handled by the installed JTA TransactionManager ?
I mean, if I am doing changes in the repository those changes will be made with the configured XA JDBC-Driver in the DB-Datastore. If a 2phace commit failes due to an error in another part of the XA transaction the changes to the Jackrabbit datastore will be rolled back by the responsible XA-JDBC Driver. So the changes made to the repository wouldn't be visible afterwards because they never were committed to the Database?

Any help how to work with Jackrabbit with XA transactions correctly is very appreciated.


Best regards
Peter Henzler

henzler informatik gmbh 
Teichstrasse 7
CH-4106 Therwil

Re: How to handle XA Transactions?

Posted by Sergey Podatelev <br...@gmail.com>.
Check this out:
http://th1rty7.blogspot.com/2009/03/spring-distributed-transactions-across.html

On Wed, May 27, 2009 at 3:39 PM, Peter Henzler <ph...@scodi.ch> wrote:
> Hi Jukka
>
> Thank you for the reply.
>
>> The sessions you get from the Repository.login() method from
>> Jackrabbit implement the org.apache.jackrabbit.api.XASession
>> interface, whose getXAResource() method can be used to attach the
>> session to a distributed XA transaction.
>
>> The nice thing about the JCA packaging is that it handles the
>> XAResource part automatically for you, but there's nothing stopping
>> you from doing the same with a little bit of code also in other
>> deployment scenarios.
>
> Do you mean code like this?:
>
>        Transaction tx = tm.getTransaction(); // get the running javax.transaction.Transaction
>        XASession session = (XASession)repository.login(creds, rename);
>        XAResource res = session.getXAResource();
>      tx.enlistResource(res);
>        // do changes in repository through the session interface
>      session.logout();
>      tx.delistResource(res, XAResource.TMSUCCESS);
>
> Or what code do you mean?
>
> Would that be enough for committing the repository changes when the global container managed XA Transaction with changes of other database connections get commited or to get rollbacked if one of those others throws an exeption?
>
>
>
>
>
>>> If I am using the Jackrabbit Datastore and Persistence configured with an XA
>>> JDBC-Driver, do I really need Transactions in Jackrabbit. Wouldn't the XA
>>> JDBC-Driver work in a 2phase commit handled by the installed JTA
>>> TransactionManager ?
>
>>No. Jackrabbit expects to be in full control of the underlying
>>database connection, so having it included in an externally managed
>>transaction is not a good idea. We've seen quite a few problems caused
>>by this.
>
> Ok, I unterstand that Jackrabbit want it's own database connection that is not used by anyone else.
> You mean that the configured JDBC Driver for the Jackrabbit repository should be a normal JDBC Driver instead of a XA JDBC Driver?
>
> Best regards
> Peter
>



-- 
sp

AW: How to handle XA Transactions?

Posted by Peter Henzler <ph...@scodi.ch>.
Hi Jukka

Thank you for the reply.

> The sessions you get from the Repository.login() method from
> Jackrabbit implement the org.apache.jackrabbit.api.XASession
> interface, whose getXAResource() method can be used to attach the
> session to a distributed XA transaction.

> The nice thing about the JCA packaging is that it handles the
> XAResource part automatically for you, but there's nothing stopping
> you from doing the same with a little bit of code also in other
> deployment scenarios.

Do you mean code like this?:

	Transaction tx = tm.getTransaction(); // get the running javax.transaction.Transaction
	XASession session = (XASession)repository.login(creds, rename);
	XAResource res = session.getXAResource();
      tx.enlistResource(res);
	// do changes in repository through the session interface
      session.logout();
      tx.delistResource(res, XAResource.TMSUCCESS);

Or what code do you mean?

Would that be enough for committing the repository changes when the global container managed XA Transaction with changes of other database connections get commited or to get rollbacked if one of those others throws an exeption?





>> If I am using the Jackrabbit Datastore and Persistence configured with an XA
>> JDBC-Driver, do I really need Transactions in Jackrabbit. Wouldn't the XA
>> JDBC-Driver work in a 2phase commit handled by the installed JTA
>> TransactionManager ?

>No. Jackrabbit expects to be in full control of the underlying
>database connection, so having it included in an externally managed
>transaction is not a good idea. We've seen quite a few problems caused
>by this.

Ok, I unterstand that Jackrabbit want it's own database connection that is not used by anyone else.
You mean that the configured JDBC Driver for the Jackrabbit repository should be a normal JDBC Driver instead of a XA JDBC Driver?

Best regards
Peter

Re: How to handle XA Transactions?

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Wed, May 27, 2009 at 11:31 AM, Peter Henzler <ph...@scodi.ch> wrote:
> Is it true, that the Jackrabbit transaction support can only work with
> UserTransactions and can't work with distributed transactions?

No.

> Is it true, that I can only get Jackrabbit working together with
> XA Transactions if I use the Jackrabbit JCA interface?

No.

The sessions you get from the Repository.login() method from
Jackrabbit implement the org.apache.jackrabbit.api.XASession
interface, whose getXAResource() method can be used to attach the
session to a distributed XA transaction.

The nice thing about the JCA packaging is that it handles the
XAResource part automatically for you, but there's nothing stopping
you from doing the same with a little bit of code also in other
deployment scenarios.

> If I am using the Jackrabbit Datastore and Persistence configured with an XA
> JDBC-Driver, do I really need Transactions in Jackrabbit. Wouldn't the XA
> JDBC-Driver work in a 2phase commit handled by the installed JTA
> TransactionManager ?

No. Jackrabbit expects to be in full control of the underlying
database connection, so having it included in an externally managed
transaction is not a good idea. We've seen quite a few problems caused
by this.

BR,

Jukka Zitting