use of org.apache.activemq.artemis.core.client.impl.ClientSessionInternal in project activemq-artemis by apache.
the class BridgeImpl method nodeUP.
// To be called by the topology update
// This logic will be updated on the cluster connection
protected void nodeUP(TopologyMember member, boolean last) {
ClientSessionInternal sessionToUse = session;
RemotingConnection connectionToUse = sessionToUse != null ? sessionToUse.getConnection() : null;
if (member != null && this.targetNodeID != null && this.targetNodeID.equals(member.getNodeId())) {
// this could be an update of the topology say after a backup started
BridgeImpl.this.targetNode = member;
} else {
// we don't need synchronization here, but we need to make sure we won't get a NPE on races
if (connectionToUse != null && member.isMember(connectionToUse)) {
this.targetNode = member;
this.targetNodeID = member.getNodeId();
}
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientSessionInternal in project activemq-artemis by apache.
the class ActiveMQRAXAResource method start.
/**
* Start
*
* @param xid A global transaction identifier
* @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME
* @throws XAException An error has occurred
*/
@Override
public void start(final Xid xid, final int flags) throws XAException {
if (ActiveMQRAXAResource.trace) {
ActiveMQRALogger.LOGGER.trace("start(" + xid + ", " + flags + ")");
}
managedConnection.lock();
ClientSessionInternal sessionInternal = (ClientSessionInternal) xaResource;
try {
try {
// this resets any tx stuff, we assume here that the tm and jca layer are well behaved when it comes to this
sessionInternal.resetIfNeeded();
} catch (ActiveMQException e) {
ActiveMQRALogger.LOGGER.problemResettingXASession(e);
XAException xaException = new XAException(XAException.XAER_RMFAIL);
xaException.initCause(e);
throw xaException;
}
xaResource.start(xid, flags);
} finally {
managedConnection.setInManagedTx(true);
managedConnection.unlock();
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientSessionInternal in project activemq-artemis by apache.
the class ActiveMQConnection method signalStopToAllSessions.
public synchronized void signalStopToAllSessions() {
for (ActiveMQSession session : sessions) {
ClientSession coreSession = session.getCoreSession();
if (coreSession instanceof ClientSessionInternal) {
ClientSessionInternal internalSession = (ClientSessionInternal) coreSession;
internalSession.setStopSignal();
}
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientSessionInternal in project activemq-artemis by apache.
the class FailureDeadlockTest method testDeadlock.
// https://jira.jboss.org/jira/browse/JBMESSAGING-1702
// Test that two failures concurrently executing and calling the same exception listener
// don't deadlock
@Test
public void testDeadlock() throws Exception {
for (int i = 0; i < 100; i++) {
final Connection conn1 = cf1.createConnection();
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
RemotingConnection rc1 = ((ClientSessionInternal) ((ActiveMQSession) sess1).getCoreSession()).getConnection();
final Connection conn2 = cf2.createConnection();
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
RemotingConnection rc2 = ((ClientSessionInternal) ((ActiveMQSession) sess2).getCoreSession()).getConnection();
ExceptionListener listener1 = new ExceptionListener() {
@Override
public void onException(final JMSException exception) {
try {
conn2.close();
} catch (Exception e) {
FailureDeadlockTest.log.error("Failed to close connection2", e);
}
}
};
conn1.setExceptionListener(listener1);
conn2.setExceptionListener(listener1);
Failer f1 = new Failer(rc1);
Failer f2 = new Failer(rc2);
f1.start();
f2.start();
f1.join();
f2.join();
conn1.close();
conn2.close();
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientSessionInternal in project activemq-artemis by apache.
the class FailureDeadlockTest method testUsingDeadConnection.
// https://jira.jboss.org/jira/browse/JBMESSAGING-1703
// Make sure that failing a connection removes it from the connection manager and can't be returned in a subsequent
// call
@Test
public void testUsingDeadConnection() throws Exception {
for (int i = 0; i < 100; i++) {
final Connection conn1 = cf1.createConnection();
Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
RemotingConnection rc1 = ((ClientSessionInternal) ((ActiveMQSession) sess1).getCoreSession()).getConnection();
rc1.fail(new ActiveMQNotConnectedException("blah"));
try {
conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
Assert.fail("should throw exception");
} catch (JMSException e) {
// pass
}
conn1.close();
}
}
Aggregations