Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] CDOTransaction or CDOXATransaction participating in XA transaction(How to make CDO repository participate in XA transaction)
[CDO] CDOTransaction or CDOXATransaction participating in XA transaction [message #1030667] Sun, 31 March 2013 14:52 Go to next message
Pavel Vlasov is currently offline Pavel Vlasov
Messages: 3
Registered: March 2013
Junior Member
Hello,

I'm wondering what is the best/recommended way to enlist CDO repository into a JTA transaction? I guess that CDO shall provide an XAResource which can be enlisted in a JTA transaction, but I couldn't find anything like that in the API.

One option is to wrap CDOTransaction or CDOXATransaction into XAResource, but in this case it is not clear what is the best way to handle prepare and rollback after that. I guess with the current API's it'd require recording changes, committing CDO transaction in prepare and playing back changes in the case of rollback.

Please advise!
---
Thank you, Pavel.
Re: [CDO] CDOTransaction or CDOXATransaction participating in XA transaction [message #1032222 is a reply to message #1030667] Tue, 02 April 2013 18:34 Go to previous messageGo to next message
Pavel Vlasov is currently offline Pavel Vlasov
Messages: 1
Registered: April 2013
Junior Member
I looked at the source of CDOXATransactionImpl and it appears that its Phase 1 & 2 map to XAResource.prepare() and Phase 3 maps to XAResource.commit(). Therefore, IMO, the easiest way to JTA enable CDO is probably to take CDOXATransactionImpl source, split its commit() method into prepare() (phase 1 & 2) and commit() (phase 3) and then wrap into/facade with XAResource. An advice from gurus whether this approach is OK or whether there is a better way is highly appreciated!
Re: [CDO] CDOTransaction or CDOXATransaction participating in XA transaction [message #1034367 is a reply to message #1032222] Fri, 05 April 2013 10:59 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5524
Registered: July 2009
Senior Member
Am 02.04.2013 21:23, schrieb Pavel Vlasov:
> I looked at the source of CDOXATransactionImpl and it appears that its Phase 1 & 2 map to XAResource.prepare() and
> Phase 3 maps to XAResource.commit(). Therefore, IMO, the easiest way to JTA enable CDO is probably to take
> CDOXATransactionImpl source, split its commit() method into prepare() (phase 1 & 2) and commit() (phase 3) and then
> wrap into/facade with XAResource. An advice from gurus whether this approach is OK or whether there is a better way is
> highly appreciated!
That's exactly what I was going to suggest ;-)

I've just committed the following changes to org.eclipse.emf.internal.cdo.transaction.CDOXATransactionImpl:

public CDOCommitInfo commit(IProgressMonitor progressMonitor) throws CommitException
{
commitPrepare(progressMonitor);
int phase = 0;

try
{
// We need to complete 3 phases
while (phase <= 2)
{
commitPhase(progressMonitor);
++phase;
}
}
catch (Exception ex)
{
commitException(progressMonitor, phase, ex);
}
finally
{
commitFinally(progressMonitor);
}

return null;
}

The following new methods could be used by JTA:

CDOXATransactionImpl.commitPrepare(IProgressMonitor)
CDOXATransactionImpl.commitPhase(IProgressMonitor)
CDOXATransactionImpl.commitException(IProgressMonitor, int, Exception)
CDOXATransactionImpl.commitFinally(IProgressMonitor)

It would be cool if you contribute your JTA wrapper. Please open a bugzilla and attach a patch. If the patch can be
accepted I'll expose the new CDOXATransactionImpl methods via InternalCDOXATransaction.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] CDOTransaction or CDOXATransaction participating in XA transaction [message #1061734 is a reply to message #1034367] Mon, 03 June 2013 16:25 Go to previous message
Pavel Vlasov is currently offline Pavel Vlasov
Messages: 3
Registered: March 2013
Junior Member
Here it is - https://bugs.eclipse.org/bugs/show_bug.cgi?id=409756
Previous Topic:property descriptor with choice of values plus user entered values
Next Topic:[CDO] Error when saving a model having two editors opened
Goto Forum:
  


Current Time: Tue Sep 23 06:40:41 GMT 2014

Powered by FUDForum. Page generated in 0.10128 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software