Package org.apache.activemq.ra
Class ManagedTransactionContext
- java.lang.Object
-
- org.apache.activemq.TransactionContext
-
- org.apache.activemq.ra.ManagedTransactionContext
-
- All Implemented Interfaces:
XAResource
public class ManagedTransactionContext extends TransactionContext
Allows us to switch between using a shared transaction context, or using a local transaction context.
-
-
Field Summary
-
Fields inherited from class org.apache.activemq.TransactionContext
xaErrorCodeMarker
-
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
-
-
Constructor Summary
Constructors Constructor Description ManagedTransactionContext(TransactionContext sharedContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSynchronization(Synchronization s)
void
begin()
Start a local transaction.void
commit()
Commits all work done in this transaction and releases any locks currently held.void
commit(Xid xid, boolean onePhase)
void
end(Xid xid, int flags)
void
forget(Xid xid)
TransactionId
getTransactionId()
int
getTransactionTimeout()
boolean
isInLocalTransaction()
boolean
isInTransaction()
boolean
isInXATransaction()
boolean
isRollbackOnly()
boolean
isSameRM(XAResource xaResource)
int
prepare(Xid xid)
Xid[]
recover(int flag)
void
rollback()
Rolls back any work done in this transaction and releases any locks currently held.void
rollback(Xid xid)
boolean
setTransactionTimeout(int seconds)
void
setUseSharedTxContext(boolean enable)
void
start(Xid xid, int flags)
Associates a transaction with the resource.-
Methods inherited from class org.apache.activemq.TransactionContext
cleanup, getConnection, getLocalTransactionEventListener, getResourceManagerId, setConnection, setLocalTransactionEventListener, setRollbackOnly, toString, toXAException
-
-
-
-
Constructor Detail
-
ManagedTransactionContext
public ManagedTransactionContext(TransactionContext sharedContext)
-
-
Method Detail
-
setUseSharedTxContext
public void setUseSharedTxContext(boolean enable) throws JMSException
- Throws:
JMSException
-
begin
public void begin() throws JMSException
Description copied from class:TransactionContext
Start a local transaction.- Overrides:
begin
in classTransactionContext
- Throws:
JMSException
- on internal error
-
commit
public void commit() throws JMSException
Description copied from class:TransactionContext
Commits all work done in this transaction and releases any locks currently held.- Overrides:
commit
in classTransactionContext
- Throws:
JMSException
- if the JMS provider fails to commit the transaction due to some internal error.IllegalStateException
- if the method is not called by a transacted session.
-
commit
public void commit(Xid xid, boolean onePhase) throws XAException
- Specified by:
commit
in interfaceXAResource
- Overrides:
commit
in classTransactionContext
- Throws:
XAException
-
end
public void end(Xid xid, int flags) throws XAException
- Specified by:
end
in interfaceXAResource
- Overrides:
end
in classTransactionContext
- Throws:
XAException
-
forget
public void forget(Xid xid) throws XAException
- Specified by:
forget
in interfaceXAResource
- Overrides:
forget
in classTransactionContext
- Throws:
XAException
-
getTransactionId
public TransactionId getTransactionId()
- Overrides:
getTransactionId
in classTransactionContext
-
getTransactionTimeout
public int getTransactionTimeout() throws XAException
- Specified by:
getTransactionTimeout
in interfaceXAResource
- Overrides:
getTransactionTimeout
in classTransactionContext
- Throws:
XAException
-
isInLocalTransaction
public boolean isInLocalTransaction()
- Overrides:
isInLocalTransaction
in classTransactionContext
-
isRollbackOnly
public boolean isRollbackOnly()
- Overrides:
isRollbackOnly
in classTransactionContext
-
isInXATransaction
public boolean isInXATransaction()
- Overrides:
isInXATransaction
in classTransactionContext
-
isInTransaction
public boolean isInTransaction()
- Overrides:
isInTransaction
in classTransactionContext
-
isSameRM
public boolean isSameRM(XAResource xaResource) throws XAException
- Specified by:
isSameRM
in interfaceXAResource
- Overrides:
isSameRM
in classTransactionContext
- Throws:
XAException
-
prepare
public int prepare(Xid xid) throws XAException
- Specified by:
prepare
in interfaceXAResource
- Overrides:
prepare
in classTransactionContext
- Throws:
XAException
-
recover
public Xid[] recover(int flag) throws XAException
- Specified by:
recover
in interfaceXAResource
- Overrides:
recover
in classTransactionContext
- Throws:
XAException
-
rollback
public void rollback() throws JMSException
Description copied from class:TransactionContext
Rolls back any work done in this transaction and releases any locks currently held.- Overrides:
rollback
in classTransactionContext
- Throws:
JMSException
- if the JMS provider fails to roll back the transaction due to some internal error.IllegalStateException
- if the method is not called by a transacted session.
-
rollback
public void rollback(Xid xid) throws XAException
- Specified by:
rollback
in interfaceXAResource
- Overrides:
rollback
in classTransactionContext
- Throws:
XAException
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds) throws XAException
- Specified by:
setTransactionTimeout
in interfaceXAResource
- Overrides:
setTransactionTimeout
in classTransactionContext
- Throws:
XAException
-
start
public void start(Xid xid, int flags) throws XAException
Description copied from class:TransactionContext
Associates a transaction with the resource.- Specified by:
start
in interfaceXAResource
- Overrides:
start
in classTransactionContext
- Throws:
XAException
-
addSynchronization
public void addSynchronization(Synchronization s)
- Overrides:
addSynchronization
in classTransactionContext
-
-