Package com.swiftmq.swiftlet.xa
Interface XAContext
-
public interface XAContextThis class acts as a context for an XA transaction. Multiple so-called 'threads of control' (ToC) can share an XAContext. Before they access it, they have to register itself to become associated with the XA transaction. Thereafter they do their work and add QueueTransactions to this context before they unregister. If no more ToCs are registered with the XAContext, the 2-phase-commit protocol is used to finish the transaction.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2003, All Rights Reserved
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddTransaction(int id, java.lang.String queueName, QueueTransaction transaction)Add a QueueTransaction to the XA transaction.voidclose()Closes this XAContext.longcommit(boolean onePhase)Performs a commit operation on all registered QueueTransactions.XidImplgetXid()Returns the Xid.booleanisPrepared()Returns whether this transaction is in the 'prepared' state.booleanisRecovered()Returns whether this transaction was recovered on startup from the prepared logvoidprepare()Performs a prepare operation on all registered QueueTransactions.intregister(java.lang.String description)Registers a new Thread of Control at this XAContext.voidrollback()Performs a rollback operation on all registered QueueTransaction.voidsetPrepared(boolean b)Sets this context to the 'prepared' statevoidunregister(int id, boolean rollbackOnly)Unregisters a ToC from this XAContext.
-
-
-
Method Detail
-
getXid
XidImpl getXid()
Returns the Xid.- Returns:
- xid.
-
isPrepared
boolean isPrepared()
Returns whether this transaction is in the 'prepared' state.- Returns:
- true/false
-
setPrepared
void setPrepared(boolean b)
Sets this context to the 'prepared' state- Parameters:
b- true/false
-
isRecovered
boolean isRecovered()
Returns whether this transaction was recovered on startup from the prepared log- Returns:
- true/false
-
register
int register(java.lang.String description) throws XAContextExceptionRegisters a new Thread of Control at this XAContext.- Parameters:
description- A description of the ToC- Returns:
- id ToC id
- Throws:
XAContextException- on error
-
addTransaction
void addTransaction(int id, java.lang.String queueName, QueueTransaction transaction) throws XAContextExceptionAdd a QueueTransaction to the XA transaction. This has to be done while the ToC is registered.- Parameters:
id- the ToC idqueueName- Name of the queuetransaction- QueueTransaction- Throws:
XAContextException- on error
-
unregister
void unregister(int id, boolean rollbackOnly) throws XAContextExceptionUnregisters a ToC from this XAContext.- Parameters:
id- ToC idrollbackOnly- marks this transaction as rollback only- Throws:
XAContextException- on error
-
prepare
void prepare() throws XAContextExceptionPerforms a prepare operation on all registered QueueTransactions. All ToCs have to be unregistered to this.- Throws:
XAContextException- on error
-
commit
long commit(boolean onePhase) throws XAContextExceptionPerforms a commit operation on all registered QueueTransactions. If 'onePhase' is set to true, a normal commit is performed, otherwise a 2PC commit is performed. All ToCs have to be unregistered to this. For 2PC commit the XAContext has to be in the prepared state (isPrepared() must return true).- Parameters:
onePhase- perform a 1PC commit.- Returns:
- Flowcontrol delay
- Throws:
XAContextException- on error.
-
rollback
void rollback() throws XAContextExceptionPerforms a rollback operation on all registered QueueTransaction. If the XAContext is in the prepared state (isPrepared() return true), a 2PC rollback is performed, otherwise a 1PC rollback (normal rollback) is performed. All ToCs have to be unregistered to this.- Throws:
XAContextException
-
close
void close()
Closes this XAContext. This method is called when the XAResourceManagerSwiftlet shuts down. If the XAContext is not in the prepared state, a normal rollback is performed on all registered QueueTransactions.
-
-