In class XAConnectionImpl there is a frequent comment:
// Technically, prepare may be called for any connection,
// not just this one.
Does this mean that the only association between a xa connection and xa resource is XID and the work done on all connections associated with the same XID can be prepared/committed/aborted by issueing one command to ANY connections?
Thanks a lot!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes but XAConnectionImpl does not support that behaviour.
"Prepare", "commit", "rollback" can be called on any XAResource at any time with any xid, however "end" can only be called on an XAResource that has been previously been called with "start" with the same xid. The reason why prepare etc act in this manner is for recovery ie during recovery you don't have the same xa resource used during the transaction but you'll need to call "prepare", "commit", "rollback".
Theoritically "end" does not need to be called with an xid but I guess the spec did that to be consistent with the other method signatures.
For example the following is valid:
xaResource1.start(xid1);
// work
xaResource1.end(xid1);
xaResource2.start(xid2);
xaResource2.prepare(xid1);
xaResource3.commit(xid1);
The following is not valid:
xaResource1.start(xid1);
// work
// assuming xaResource2.start(xid2); is not called
xaResource2.end(xid1);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2002-09-03
I have a C++ program that manages and uses a pool of database connections (pointing to different databases). Is there a way for the work done on these connections to be part of a global transaction started in a Tyrex? Can I enlist a XAResource that points to the db I am going to use in my C++ program, acquire the XID from the transaction manager, associate the work done in my C++ program with the same XID and ask Tyrex to coordinate commit/rollback?
Thanks a lot!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In class XAConnectionImpl there is a frequent comment:
// Technically, prepare may be called for any connection,
// not just this one.
Does this mean that the only association between a xa connection and xa resource is XID and the work done on all connections associated with the same XID can be prepared/committed/aborted by issueing one command to ANY connections?
Thanks a lot!
Yes but XAConnectionImpl does not support that behaviour.
"Prepare", "commit", "rollback" can be called on any XAResource at any time with any xid, however "end" can only be called on an XAResource that has been previously been called with "start" with the same xid. The reason why prepare etc act in this manner is for recovery ie during recovery you don't have the same xa resource used during the transaction but you'll need to call "prepare", "commit", "rollback".
Theoritically "end" does not need to be called with an xid but I guess the spec did that to be consistent with the other method signatures.
For example the following is valid:
xaResource1.start(xid1);
// work
xaResource1.end(xid1);
xaResource2.start(xid2);
xaResource2.prepare(xid1);
xaResource3.commit(xid1);
The following is not valid:
xaResource1.start(xid1);
// work
// assuming xaResource2.start(xid2); is not called
xaResource2.end(xid1);
I have a C++ program that manages and uses a pool of database connections (pointing to different databases). Is there a way for the work done on these connections to be part of a global transaction started in a Tyrex? Can I enlist a XAResource that points to the db I am going to use in my C++ program, acquire the XID from the transaction manager, associate the work done in my C++ program with the same XID and ask Tyrex to coordinate commit/rollback?
Thanks a lot!