Class ActiveMQXAResourceWrapper
- java.lang.Object
-
- org.apache.activemq.artemis.service.extensions.xa.recovery.ActiveMQXAResourceWrapper
-
- All Implemented Interfaces:
XAResource,SessionFailureListener,org.apache.activemq.artemis.core.remoting.FailureListener
public class ActiveMQXAResourceWrapper extends Object implements XAResource, SessionFailureListener
XAResourceWrapper. Mainly from org.jboss.server.XAResourceWrapper from the JBoss AS server module The reason why we don't use that class directly is that it assumes on failure of connection the RM_FAIL or RM_ERR is thrown, but in ActiveMQ Artemis we throw XA_RETRY since we want the recovery manager to be able to retry on failure without having to manually retry
-
-
Field Summary
-
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 ActiveMQXAResourceWrapper(XARecoveryConfig... xaRecoveryConfigs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeReconnect(ActiveMQException me)protected XAExceptioncheck(XAException e)Check whether an XAException is fatal.voidclose()Close the connectionvoidcommit(Xid xid, boolean onePhase)protected XAResourceconnect()Connect to the server if not already done sovoidconnectionFailed(ActiveMQException me, boolean failedOver)voidconnectionFailed(ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID)voidend(Xid xid, int flags)voidforget(Xid xid)intgetTransactionTimeout()booleanisSameRM(XAResource xaRes)intprepare(Xid xid)Xid[]recover(int flag)voidrollback(Xid xid)booleansetTransactionTimeout(int seconds)voidstart(Xid xid, int flags)StringtoString()voidupdateRecoveryConfig(XARecoveryConfig... xaRecoveryConfigs)
-
-
-
Constructor Detail
-
ActiveMQXAResourceWrapper
public ActiveMQXAResourceWrapper(XARecoveryConfig... xaRecoveryConfigs)
-
-
Method Detail
-
updateRecoveryConfig
public void updateRecoveryConfig(XARecoveryConfig... xaRecoveryConfigs)
-
recover
public Xid[] recover(int flag) throws XAException
- Specified by:
recoverin interfaceXAResource- Throws:
XAException
-
commit
public void commit(Xid xid, boolean onePhase) throws XAException
- Specified by:
commitin interfaceXAResource- Throws:
XAException
-
rollback
public void rollback(Xid xid) throws XAException
- Specified by:
rollbackin interfaceXAResource- Throws:
XAException
-
forget
public void forget(Xid xid) throws XAException
- Specified by:
forgetin interfaceXAResource- Throws:
XAException
-
isSameRM
public boolean isSameRM(XAResource xaRes) throws XAException
- Specified by:
isSameRMin interfaceXAResource- Throws:
XAException
-
prepare
public int prepare(Xid xid) throws XAException
- Specified by:
preparein interfaceXAResource- Throws:
XAException
-
start
public void start(Xid xid, int flags) throws XAException
- Specified by:
startin interfaceXAResource- Throws:
XAException
-
end
public void end(Xid xid, int flags) throws XAException
- Specified by:
endin interfaceXAResource- Throws:
XAException
-
getTransactionTimeout
public int getTransactionTimeout() throws XAException- Specified by:
getTransactionTimeoutin interfaceXAResource- Throws:
XAException
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds) throws XAException- Specified by:
setTransactionTimeoutin interfaceXAResource- Throws:
XAException
-
connectionFailed
public void connectionFailed(ActiveMQException me, boolean failedOver)
- Specified by:
connectionFailedin interfaceorg.apache.activemq.artemis.core.remoting.FailureListener
-
connectionFailed
public void connectionFailed(ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID)
- Specified by:
connectionFailedin interfaceorg.apache.activemq.artemis.core.remoting.FailureListener
-
beforeReconnect
public void beforeReconnect(ActiveMQException me)
- Specified by:
beforeReconnectin interfaceSessionFailureListener
-
connect
protected XAResource connect() throws Exception
Connect to the server if not already done so- Returns:
- the connectionFactory XAResource
- Throws:
Exception- for any problem
-
close
public void close()
Close the connection
-
check
protected XAException check(XAException e) throws XAException
Check whether an XAException is fatal. If it is an RM problem we close the connection so the next call will reconnect.- Parameters:
e- the xa exception- Returns:
- never
- Throws:
XAException- always
-
-