Class ActiveMQXAResourceWrapper
- java.lang.Object
-
- org.apache.activemq.artemis.service.extensions.xa.recovery.ActiveMQXAResourceWrapper
-
- All Implemented Interfaces:
XAResource,SessionFailureListener,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)Notifies that a connection has failed due to the specified exception.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)Notifies that a connection has failed due to the specified exception.voidconnectionFailed(ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID)Notifies that a connection has failed due to the specified exception.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()
-
-
-
Constructor Detail
-
ActiveMQXAResourceWrapper
public ActiveMQXAResourceWrapper(XARecoveryConfig... xaRecoveryConfigs)
-
-
Method Detail
-
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)
Description copied from interface:FailureListenerNotifies that a connection has failed due to the specified exception.- Specified by:
connectionFailedin interfaceFailureListener- Parameters:
me- exception which has caused the connection to fail
-
connectionFailed
public void connectionFailed(ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID)
Description copied from interface:FailureListenerNotifies that a connection has failed due to the specified exception.- Specified by:
connectionFailedin interfaceFailureListener- Parameters:
me- exception which has caused the connection to failscaleDownTargetNodeID- the ID of the node to which messages are scaling down
-
beforeReconnect
public void beforeReconnect(ActiveMQException me)
Description copied from interface:SessionFailureListenerNotifies that a connection has failed due to the specified exception.
This method is called before the session attempts to reconnect/failover.- Specified by:
beforeReconnectin interfaceSessionFailureListener- Parameters:
me- exception which has caused the connection to fail
-
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
-
-