Here are the examples of the java api class org.apache.activemq.artemis.spi.core.protocol.RemotingConnection taken from open source projects.
1. ReplicatedDistributionTest#fail()
Project: activemq-artemis
File: ReplicatedDistributionTest.java
File: ReplicatedDistributionTest.java
/** * @param session * @throws InterruptedException */ private void fail(final ClientSession session) throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); session.addFailureListener(new CountDownSessionFailureListener(latch, session)); RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); // Simulate failure on connection conn.fail(new ActiveMQNotConnectedException()); // Wait to be informed of failure boolean ok = latch.await(1000, TimeUnit.MILLISECONDS); Assert.assertTrue(ok); }
2. ClientSessionFactoryImpl#establishNewConnection()
Project: activemq-artemis
File: ClientSessionFactoryImpl.java
File: ClientSessionFactoryImpl.java
protected RemotingConnection establishNewConnection() { Connection transportConnection = createTransportConnection(); if (transportConnection == null) { if (ClientSessionFactoryImpl.logger.isTraceEnabled()) { logger.trace("Neither backup or live were active, will just give up now"); } return null; } RemotingConnection newConnection = clientProtocolManager.connect(transportConnection, callTimeout, callFailoverTimeout, incomingInterceptors, outgoingInterceptors, new SessionFactoryTopologyHandler()); newConnection.addFailureListener(new DelegatingFailureListener(newConnection.getID())); schedulePing(); if (logger.isTraceEnabled()) { logger.trace("returning " + newConnection); } return newConnection; }
3. PingTest#testNoFailureNoPinging()
Project: activemq-artemis
File: PingTest.java
File: PingTest.java
/* * Test that no failure listeners are triggered in a non failure case with no pinging going on */ @Test public void testNoFailureNoPinging() throws Exception { TransportConfiguration transportConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(transportConfig)); locator.setClientFailureCheckPeriod(-1); locator.setConnectionTTL(-1); ClientSessionFactory csf = createSessionFactory(locator); ClientSession session = csf.createSession(false, true, true); Assert.assertEquals(1, ((ClientSessionFactoryInternal) csf).numConnections()); Listener clientListener = new Listener(); session.addFailureListener(clientListener); RemotingConnection serverConn = null; while (serverConn == null) { Set<RemotingConnection> conns = server.getRemotingService().getConnections(); if (!conns.isEmpty()) { serverConn = server.getRemotingService().getConnections().iterator().next(); } else { // It's async so need to wait a while Thread.sleep(10); } } Listener serverListener = new Listener(); serverConn.addFailureListener(serverListener); Thread.sleep(ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD); Assert.assertNull(clientListener.getException()); Assert.assertNull(serverListener.getException()); RemotingConnection serverConn2 = server.getRemotingService().getConnections().iterator().next(); PingTest.log.info("Serverconn2 is " + serverConn2); Assert.assertTrue(serverConn == serverConn2); session.close(); csf.close(); locator.close(); }
4. PingTest#testNoFailureWithPinging()
Project: activemq-artemis
File: PingTest.java
File: PingTest.java
/* * Test that no failure listeners are triggered in a non failure case with pinging going on */ @Test public void testNoFailureWithPinging() throws Exception { ServerLocator locator = createNettyNonHALocator(); locator.setClientFailureCheckPeriod(PingTest.CLIENT_FAILURE_CHECK_PERIOD); locator.setConnectionTTL(PingTest.CLIENT_FAILURE_CHECK_PERIOD * 2); ClientSessionFactory csf = createSessionFactory(locator); ClientSession session = csf.createSession(false, true, true); PingTest.log.info("Created session"); Assert.assertEquals(1, ((ClientSessionFactoryInternal) csf).numConnections()); Listener clientListener = new Listener(); session.addFailureListener(clientListener); RemotingConnection serverConn = null; while (serverConn == null) { Set<RemotingConnection> conns = server.getRemotingService().getConnections(); if (!conns.isEmpty()) { serverConn = server.getRemotingService().getConnections().iterator().next(); } else { // It's async so need to wait a while Thread.sleep(10); } } Listener serverListener = new Listener(); serverConn.addFailureListener(serverListener); Thread.sleep(PingTest.CLIENT_FAILURE_CHECK_PERIOD * 10); Assert.assertNull(clientListener.getException()); Assert.assertNull(serverListener.getException()); RemotingConnection serverConn2 = server.getRemotingService().getConnections().iterator().next(); PingTest.log.info("Server conn2 is " + serverConn2); Assert.assertTrue(serverConn == serverConn2); session.close(); csf.close(); locator.close(); }
5. BindingsClusterTest#crash()
Project: activemq-artemis
File: BindingsClusterTest.java
File: BindingsClusterTest.java
private void crash() throws Exception { /* * Rather than just calling stop() on the server here we want to simulate an actual node crash or bridge failure * so the bridge's failure listener needs to get something other than a DISCONNECTED message. In this case we * simulate a NOT_CONNECTED exception. */ final CountDownLatch latch = new CountDownLatch(1); ClusterConnectionImpl next = (ClusterConnectionImpl) server1.getClusterManager().getClusterConnections().iterator().next(); BridgeImpl bridge = (BridgeImpl) next.getRecords().values().iterator().next().getBridge(); RemotingConnection forwardingConnection = getForwardingConnection(bridge); forwardingConnection.addFailureListener(new FailureListener() { @Override public void connectionFailed(ActiveMQException exception, boolean failedOver) { latch.countDown(); } @Override public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) { connectionFailed(me, failedOver); } }); forwardingConnection.fail(new ActiveMQNotConnectedException()); assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); if (crash) { jmsServer2.stop(); } }
6. ReattachTest#testAsyncFailureWhileReattaching()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
// Test an async (e.g. pinger) failure coming in while a connection manager is already reconnecting @Test public void testAsyncFailureWhileReattaching() throws Exception { final long retryInterval = 500; final double retryMultiplier = 1d; final int reconnectAttempts = -1; final long asyncFailDelay = 2000; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); ClientSession session2 = sf.createSession(false, true, true); class MyFailureListener implements SessionFailureListener { volatile boolean failed; @Override public void connectionFailed(final ActiveMQException me, boolean failedOver) { failed = true; } @Override public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) { connectionFailed(me, failedOver); } @Override public void beforeReconnect(final ActiveMQException exception) { } } MyFailureListener listener = new MyFailureListener(); session2.addFailureListener(listener); session.createQueue(ReattachTest.ADDRESS, ReattachTest.ADDRESS, null, false); ClientProducer producer = session.createProducer(ReattachTest.ADDRESS); final int numMessages = 1000; for (int i = 0; i < numMessages; i++) { ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); message.putIntProperty(new SimpleString("count"), i); message.getBodyBuffer().writeString("aardvarks"); producer.send(message); } ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS); InVMConnector.numberOfFailures = 10; InVMConnector.failOnCreateConnection = true; final RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); final RemotingConnection conn2 = ((ClientSessionInternal) session2).getConnection(); Thread t = new Thread() { @Override public void run() { try { Thread.sleep(asyncFailDelay); } catch (InterruptedException ignore) { } conn2.fail(new ActiveMQNotConnectedException("Did not receive pong from server")); } }; t.start(); conn.fail(new ActiveMQNotConnectedException()); Assert.assertTrue(listener.failed); session.start(); for (int i = 0; i < numMessages; i++) { ClientMessage message = consumer.receive(500); Assert.assertNotNull(message); Assert.assertEquals("aardvarks", message.getBodyBuffer().readString()); Assert.assertEquals(i, message.getIntProperty("count").intValue()); message.acknowledge(); } ClientMessage message = consumer.receiveImmediate(); Assert.assertNull(message); session.close(); session2.close(); sf.close(); t.join(); }
7. BridgeReconnectTest#testFailoverThenFailAgainAndReconnect()
Project: activemq-artemis
File: BridgeReconnectTest.java
File: BridgeReconnectTest.java
@Test public void testFailoverThenFailAgainAndReconnect() throws Exception { server0 = createActiveMQServer(0, isNetty(), server0Params); TransportConfiguration server0tc = new TransportConfiguration(getConnector(), server0Params, "server0tc"); server0.getConfiguration().setConnectorConfigurations(connectors); BridgeConfiguration bridgeConfiguration = createBridgeConfig(); List<BridgeConfiguration> bridgeConfigs = new ArrayList<>(); bridgeConfigs.add(bridgeConfiguration); server0.getConfiguration().setBridgeConfigurations(bridgeConfigs); CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName); List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<>(); queueConfigs0.add(queueConfig0); server0.getConfiguration().setQueueConfigurations(queueConfigs0); CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration().setAddress(forwardAddress).setName(queueName); List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<>(); queueConfigs1.add(queueConfig1); server1.getConfiguration().setQueueConfigurations(queueConfigs1); startServers(); locator = addServerLocator(ActiveMQClient.createServerLocatorWithHA(server0tc, server1tc)); ClientSessionFactory csf0 = locator.createSessionFactory(server0tc); session0 = csf0.createSession(false, true, true); ClientSessionFactory csf1 = locator.createSessionFactory(server1tc); session1 = csf1.createSession(false, true, true); ClientProducer prod0 = session0.createProducer(testAddress); ClientConsumer cons1 = session1.createConsumer(queueName); session1.start(); Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName); RemotingConnection forwardingConnection = getForwardingConnection(bridge); InVMConnector.failOnCreateConnection = true; InVMConnector.numberOfFailures = reconnectAttempts - 1; forwardingConnection.fail(new ActiveMQNotConnectedException()); final int numMessages = NUM_MESSAGES; SimpleString propKey = new SimpleString("propkey"); for (int i = 0; i < numMessages; i++) { ClientMessage message = session0.createMessage(false); message.putIntProperty(propKey, i); prod0.send(message); } int outOfOrder = -1; int supposed = -1; for (int i = 0; i < numMessages; i++) { ClientMessage r1 = cons1.receive(1500); assertNotNull(r1); if (outOfOrder == -1 && i != r1.getIntProperty(propKey).intValue()) { outOfOrder = r1.getIntProperty(propKey).intValue(); supposed = i; } } if (outOfOrder != -1) { fail("Message " + outOfOrder + " was received out of order, it was supposed to be " + supposed); } log.info("=========== second failure, sending message"); // Fail again - should reconnect forwardingConnection = ((BridgeImpl) bridge).getForwardingConnection(); InVMConnector.failOnCreateConnection = true; InVMConnector.numberOfFailures = reconnectAttempts - 1; forwardingConnection.fail(new ActiveMQException(ActiveMQExceptionType.UNBLOCKED)); for (int i = 0; i < numMessages; i++) { ClientMessage message = session0.createMessage(false); message.putIntProperty(propKey, i); prod0.send(message); } for (int i = 0; i < numMessages; i++) { ClientMessage r1 = cons1.receive(1500); assertNotNull("Didn't receive message", r1); if (outOfOrder == -1 && i != r1.getIntProperty(propKey).intValue()) { outOfOrder = r1.getIntProperty(propKey).intValue(); supposed = i; } } if (outOfOrder != -1) { fail("Message " + outOfOrder + " was received out of order, it was supposed to be " + supposed); } closeServers(); assertNoMoreConnections(); }
8. BridgeReconnectTest#testReconnectSameNode()
Project: activemq-artemis
File: BridgeReconnectTest.java
File: BridgeReconnectTest.java
// Fail bridge and reconnect same node, no backup specified @Test public void testReconnectSameNode() throws Exception { server0 = createActiveMQServer(0, isNetty(), server0Params); TransportConfiguration server0tc = new TransportConfiguration(getConnector(), server0Params, "server0tc"); server0.getConfiguration().setConnectorConfigurations(connectors); server1.getConfiguration().setConnectorConfigurations(connectors); BridgeConfiguration bridgeConfiguration = createBridgeConfig(); List<BridgeConfiguration> bridgeConfigs = new ArrayList<>(); bridgeConfigs.add(bridgeConfiguration); server0.getConfiguration().setBridgeConfigurations(bridgeConfigs); CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName); List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<>(); queueConfigs0.add(queueConfig0); server0.getConfiguration().setQueueConfigurations(queueConfigs0); CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration().setAddress(forwardAddress).setName(queueName); List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<>(); queueConfigs1.add(queueConfig1); server1.getConfiguration().setQueueConfigurations(queueConfigs1); startServers(); locator = addServerLocator(ActiveMQClient.createServerLocatorWithHA(server0tc, server1tc)); ClientSessionFactory csf0 = locator.createSessionFactory(server0tc); session0 = csf0.createSession(false, true, true); ClientSessionFactory csf1 = locator.createSessionFactory(server1tc); session1 = csf1.createSession(false, true, true); ClientProducer prod0 = session0.createProducer(testAddress); ClientConsumer cons1 = session1.createConsumer(queueName); session1.start(); // Now we will simulate a failure of the bridge connection between server0 and server1 Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName); assertNotNull(bridge); RemotingConnection forwardingConnection = getForwardingConnection(bridge); InVMConnector.failOnCreateConnection = true; InVMConnector.numberOfFailures = reconnectAttempts - 1; forwardingConnection.fail(new ActiveMQNotConnectedException()); forwardingConnection = getForwardingConnection(bridge); forwardingConnection.fail(new ActiveMQNotConnectedException()); final ManagementService managementService = server0.getManagementService(); QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queueName); assertEquals(0, coreQueueControl.getDeliveringCount()); final int numMessages = NUM_MESSAGES; SimpleString propKey = new SimpleString("propkey"); for (int i = 0; i < numMessages; i++) { ClientMessage message = session0.createMessage(false); message.putIntProperty(propKey, i); prod0.send(message); } for (int i = 0; i < numMessages; i++) { ClientMessage r1 = cons1.receive(1500); assertNotNull(r1); assertEquals(i, r1.getObjectProperty(propKey)); } closeServers(); assertNoMoreConnections(); }
9. PingTest#testServerFailureNoPing()
Project: activemq-artemis
File: PingTest.java
File: PingTest.java
/* * Test the server timing out a connection since it doesn't receive a ping in time */ @Test public void testServerFailureNoPing() throws Exception { TransportConfiguration transportConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(transportConfig)); locator.setClientFailureCheckPeriod(PingTest.CLIENT_FAILURE_CHECK_PERIOD); locator.setConnectionTTL(PingTest.CLIENT_FAILURE_CHECK_PERIOD * 2); ClientSessionFactoryImpl csf = (ClientSessionFactoryImpl) createSessionFactory(locator); Listener clientListener = new Listener(); ClientSession session = csf.createSession(false, true, true); Assert.assertEquals(1, csf.numConnections()); session.addFailureListener(clientListener); // We need to get it to stop pinging after one csf.stopPingingAfterOne(); RemotingConnection serverConn = null; while (serverConn == null) { Set<RemotingConnection> conns = server.getRemotingService().getConnections(); if (!conns.isEmpty()) { serverConn = server.getRemotingService().getConnections().iterator().next(); } else { // It's async so need to wait a while Thread.sleep(10); } } Listener serverListener = new Listener(); serverConn.addFailureListener(serverListener); for (int i = 0; i < 1000; i++) { // a few tries to avoid a possible race caused by GCs or similar issues if (server.getRemotingService().getConnections().isEmpty() && clientListener.getException() != null) { break; } Thread.sleep(10); } if (!server.getRemotingService().getConnections().isEmpty()) { RemotingConnection serverConn2 = server.getRemotingService().getConnections().iterator().next(); PingTest.log.info("Serverconn2 is " + serverConn2); } Assert.assertTrue(server.getRemotingService().getConnections().isEmpty()); // The client listener should be called too since the server will close it from the server side which will result // in the // netty detecting closure on the client side and then calling failure listener Assert.assertNotNull(clientListener.getException()); Assert.assertNotNull(serverListener.getException()); session.close(); csf.close(); locator.close(); }
10. CloseDestroyedConnectionTest#testCloseDestroyedConnection()
Project: activemq-artemis
File: CloseDestroyedConnectionTest.java
File: CloseDestroyedConnectionTest.java
/* * Closing a connection that is destroyed should cleanly close everything without throwing exceptions */ @Test public void testCloseDestroyedConnection() throws Exception { long connectionTTL = 500; cf.setClientFailureCheckPeriod(connectionTTL / 2); // Need to set connection ttl to a low figure so connections get removed quickly on the server cf.setConnectionTTL(connectionTTL); conn = cf.createConnection(); Assert.assertEquals(1, server.getRemotingService().getConnections().size()); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); // Give time for the initial ping to reach the server before we fail (it has connection TTL in it) Thread.sleep(500); String queueName = "myqueue"; Queue queue = ActiveMQJMSClient.createQueue(queueName); super.createQueue(queueName); sess.createConsumer(queue); sess.createProducer(queue); sess.createBrowser(queue); // Now fail the underlying connection ClientSessionInternal sessi = (ClientSessionInternal) ((ActiveMQSession) sess).getCoreSession(); RemotingConnection rc = sessi.getConnection(); rc.fail(new ActiveMQInternalErrorException()); // Now close the connection conn.close(); long start = System.currentTimeMillis(); while (true) { int cons = server.getRemotingService().getConnections().size(); if (cons == 0) { break; } long now = System.currentTimeMillis(); if (now - start > 10000) { throw new Exception("Timed out waiting for connections to close"); } Thread.sleep(50); } }
11. JMSReconnectTest#testReconnectOrReattachSameNode()
Project: activemq-artemis
File: JMSReconnectTest.java
File: JMSReconnectTest.java
private void testReconnectOrReattachSameNode(boolean reattach) throws Exception { ActiveMQConnectionFactory jbcf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); jbcf.setBlockOnDurableSend(true); jbcf.setBlockOnNonDurableSend(true); jbcf.setReconnectAttempts(-1); if (reattach) { jbcf.setConfirmationWindowSize(1024 * 1024); } // Note we set consumer window size to a value so we can verify that consumer credit re-sending // works properly on failover // The value is small enough that credits will have to be resent several time final int numMessages = 10; final int bodySize = 1000; jbcf.setConsumerWindowSize(numMessages * bodySize / 10); Connection conn = jbcf.createConnection(); MyExceptionListener listener = new MyExceptionListener(); conn.setExceptionListener(listener); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); ClientSession coreSession = ((ActiveMQSession) sess).getCoreSession(); RemotingConnection coreConn = ((ClientSessionInternal) coreSession).getConnection(); SimpleString jmsQueueName = new SimpleString(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX + "myqueue"); coreSession.createQueue(jmsQueueName, jmsQueueName, null, true); Queue queue = sess.createQueue("myqueue"); MessageProducer producer = sess.createProducer(queue); producer.setDeliveryMode(DeliveryMode.PERSISTENT); MessageConsumer consumer = sess.createConsumer(queue); byte[] body = RandomUtil.randomBytes(bodySize); for (int i = 0; i < numMessages; i++) { BytesMessage bm = sess.createBytesMessage(); bm.writeBytes(body); producer.send(bm); } conn.start(); Thread.sleep(2000); ActiveMQException me = new ActiveMQNotConnectedException(); coreConn.fail(me); for (int i = 0; i < numMessages; i++) { BytesMessage bm = (BytesMessage) consumer.receive(1000); Assert.assertNotNull(bm); Assert.assertEquals(body.length, bm.getBodyLength()); } TextMessage tm = (TextMessage) consumer.receiveNoWait(); Assert.assertNull(tm); conn.close(); Assert.assertNotNull(listener.e); Assert.assertTrue(me == listener.e.getCause()); }
12. GroupingTest#testGroupingRollbackOnClose()
Project: activemq-artemis
File: GroupingTest.java
File: GroupingTest.java
@Test public void testGroupingRollbackOnClose() throws Exception { ActiveMQConnectionFactory fact = (ActiveMQConnectionFactory) getCF(); fact.setConsumerWindowSize(1000); fact.setTransactionBatchSize(0); Connection connection = fact.createConnection(); RemotingConnection rc = server.getRemotingService().getConnections().iterator().next(); Connection connection2 = fact.createConnection(); Session session = connection.createSession(true, Session.SESSION_TRANSACTED); Session session2 = connection2.createSession(true, Session.SESSION_TRANSACTED); MessageProducer producer = session.createProducer(queue); MessageConsumer consumer1 = session.createConsumer(queue); MessageConsumer consumer2 = session2.createConsumer(queue); connection.start(); connection2.start(); String jmsxgroupID = null; for (int j = 0; j < 100; j++) { TextMessage message = session.createTextMessage(); message.setText("Message" + j); setProperty(message); producer.send(message); String prop = message.getStringProperty("JMSXGroupID"); assertNotNull(prop); if (jmsxgroupID != null) { assertEquals(jmsxgroupID, prop); } else { jmsxgroupID = prop; } } session.commit(); //consume 5 msgs from 1st first consumer for (int j = 0; j < 1; j++) { TextMessage tm = (TextMessage) consumer1.receive(10000); assertNotNull(tm); assertEquals("Message" + j, tm.getText()); assertEquals(tm.getStringProperty("JMSXGroupID"), jmsxgroupID); } Thread.sleep(2000); //session.rollback(); //session.close(); //consume all msgs from 2nd first consumer // ClientSession amqs = ((ActiveMQSession) session).getCoreSession(); // ((DelegatingSession) amqs).getChannel().close(); rc.fail(new ActiveMQNotConnectedException()); for (int j = 0; j < 10; j++) { TextMessage tm = (TextMessage) consumer2.receive(10000); assertNotNull(tm); long text = ((ActiveMQTextMessage) tm).getCoreMessage().getMessageID(); System.out.println(tm.getJMSMessageID() + " text = " + text); //assertEquals("Message" + j, text); assertEquals(tm.getStringProperty("JMSXGroupID"), jmsxgroupID); } connection.close(); connection2.close(); }
13. ReattachTest#testExponentialBackoffMaxRetryInterval()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
@Test public void testExponentialBackoffMaxRetryInterval() throws Exception { final long retryInterval = 500; final double retryMultiplier = 2d; final int reconnectAttempts = -1; final long maxRetryInterval = 1000; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setMaxRetryInterval(maxRetryInterval).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(ReattachTest.ADDRESS, ReattachTest.ADDRESS, null, false); ClientProducer producer = session.createProducer(ReattachTest.ADDRESS); final int numMessages = 1000; for (int i = 0; i < numMessages; i++) { ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); message.putIntProperty(new SimpleString("count"), i); message.getBodyBuffer().writeString("aardvarks"); producer.send(message); } ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS); InVMConnector.failOnCreateConnection = true; InVMConnector.numberOfFailures = 3; RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); long start = System.currentTimeMillis(); conn.fail(new ActiveMQNotConnectedException()); session.start(); for (int i = 0; i < numMessages; i++) { ClientMessage message = consumer.receive(500); Assert.assertNotNull(message); Assert.assertEquals("aardvarks", message.getBodyBuffer().readString()); Assert.assertEquals(i, message.getIntProperty("count").intValue()); message.acknowledge(); } ClientMessage message = consumer.receiveImmediate(); Assert.assertNull(message); long end = System.currentTimeMillis(); double wait = retryInterval + retryMultiplier * 2 * retryInterval + retryMultiplier; Assert.assertTrue(end - start >= wait); Assert.assertTrue(end - start < wait + 500); session.close(); sf.close(); }
14. ReattachTest#testExponentialBackoff()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
@Test public void testExponentialBackoff() throws Exception { final long retryInterval = 500; final double retryMultiplier = 2d; final int reconnectAttempts = -1; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(ReattachTest.ADDRESS, ReattachTest.ADDRESS, null, false); ClientProducer producer = session.createProducer(ReattachTest.ADDRESS); final int numMessages = 1000; for (int i = 0; i < numMessages; i++) { ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); message.putIntProperty(new SimpleString("count"), i); message.getBodyBuffer().writeString("aardvarks"); producer.send(message); } ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS); InVMConnector.failOnCreateConnection = true; InVMConnector.numberOfFailures = 3; RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); long start = System.currentTimeMillis(); conn.fail(new ActiveMQNotConnectedException()); session.start(); for (int i = 0; i < numMessages; i++) { ClientMessage message = consumer.receive(500); Assert.assertNotNull(message); Assert.assertEquals("aardvarks", message.getBodyBuffer().readString()); Assert.assertEquals(i, message.getObjectProperty(new SimpleString("count"))); message.acknowledge(); } ClientMessage message = consumer.receiveImmediate(); Assert.assertNull(message); long end = System.currentTimeMillis(); double wait = retryInterval + retryMultiplier * retryInterval + retryMultiplier * retryMultiplier * retryInterval; Assert.assertTrue(end - start >= wait); session.close(); sf.close(); }
15. ReattachTest#testRetryInterval()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
@Test public void testRetryInterval() throws Exception { final long retryInterval = 500; final double retryMultiplier = 1d; final int reconnectAttempts = -1; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(ReattachTest.ADDRESS, ReattachTest.ADDRESS, null, false); ClientProducer producer = session.createProducer(ReattachTest.ADDRESS); final int numMessages = 1000; for (int i = 0; i < numMessages; i++) { ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); message.putIntProperty(new SimpleString("count"), i); message.getBodyBuffer().writeString("aardvarks"); producer.send(message); } ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS); InVMConnector.failOnCreateConnection = true; RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); long start = System.currentTimeMillis(); Thread t = new Thread() { @Override public void run() { try { Thread.sleep(retryInterval / 2); } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; } }; t.start(); conn.fail(new ActiveMQNotConnectedException()); session.start(); for (int i = 0; i < numMessages; i++) { ClientMessage message = consumer.receive(500); Assert.assertNotNull(message); Assert.assertEquals("aardvarks", message.getBodyBuffer().readString()); Assert.assertEquals(i, message.getIntProperty("count").intValue()); message.acknowledge(); } ClientMessage message = consumer.receiveImmediate(); Assert.assertNull(message); long end = System.currentTimeMillis(); Assert.assertTrue(end - start >= retryInterval); session.close(); sf.close(); t.join(); }
16. ReattachTest#testReattachAttemptsSucceedsInReconnecting()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
@Test public void testReattachAttemptsSucceedsInReconnecting() throws Exception { final long retryInterval = 500; final double retryMultiplier = 1d; final int reconnectAttempts = 10; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(ReattachTest.ADDRESS, ReattachTest.ADDRESS, null, false); ClientProducer producer = session.createProducer(ReattachTest.ADDRESS); final int numMessages = 1000; for (int i = 0; i < numMessages; i++) { ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); message.putIntProperty(new SimpleString("count"), i); message.getBodyBuffer().writeString("aardvarks"); producer.send(message); } ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS); InVMConnector.failOnCreateConnection = true; InVMConnector.numberOfFailures = reconnectAttempts - 1; RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); conn.fail(new ActiveMQNotConnectedException()); session.start(); for (int i = 0; i < numMessages; i++) { ClientMessage message = consumer.receive(500); Assert.assertNotNull(message); Assert.assertEquals("aardvarks", message.getBodyBuffer().readString()); Assert.assertEquals(i, message.getIntProperty("count").intValue()); message.acknowledge(); } ClientMessage message = consumer.receiveImmediate(); Assert.assertNull(message); session.close(); sf.close(); }
17. ReattachTest#testCreateQueue()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
@Test public void testCreateQueue() throws Exception { final long retryInterval = 50; final double retryMultiplier = 1d; final int reconnectAttempts = -1; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); // Sleep 3 times retryInterval, so it should at least have 3 retries RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); InVMConnector.failOnCreateConnection = false; conn.fail(new ActiveMQNotConnectedException()); Thread t = new Thread() { @Override public void run() { try { Thread.sleep(retryInterval * 3); } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; } }; t.start(); for (int i = 0; i < 10; i++) { session.createQueue("address", "queue" + i); } // // InVMConnector.failOnCreateConnection = true; // // //Should throw exception since didn't reconnect // // try // { // session.start(); // // fail("Should throw exception"); // } // catch (ActiveMQException e) // { // assertEquals(ActiveMQException.OBJECT_CLOSED, e.getCode()); // } session.close(); sf.close(); t.join(); }
18. ReattachTest#testReattachAttemptsFailsToReconnect()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
@Test public void testReattachAttemptsFailsToReconnect() throws Exception { final long retryInterval = 500; final double retryMultiplier = 1d; final int reconnectAttempts = 3; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(ReattachTest.ADDRESS, ReattachTest.ADDRESS, null, false); ClientProducer producer = session.createProducer(ReattachTest.ADDRESS); final int numMessages = 1000; for (int i = 0; i < numMessages; i++) { ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); message.putIntProperty(new SimpleString("count"), i); message.getBodyBuffer().writeString("aardvarks"); producer.send(message); } session.createConsumer(ReattachTest.ADDRESS); InVMConnector.failOnCreateConnection = true; RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); // Sleep for longer than max retries so should fail to reconnect Thread t = new Thread() { @Override public void run() { try { Thread.sleep(retryInterval * (reconnectAttempts + 1)); } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; } }; t.start(); conn.fail(new ActiveMQNotConnectedException()); try { session.start(); Assert.fail("Should throw exception"); } catch (ActiveMQObjectClosedException oce) { } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); sf.close(); t.join(); }
19. ReattachTest#testDelayedReattach()
Project: activemq-artemis
File: ReattachTest.java
File: ReattachTest.java
/* * Test failure on connection, simulate failure to create connection for a while, then * allow connection to be recreated */ @Test public void testDelayedReattach() throws Exception { final long retryInterval = 500; final double retryMultiplier = 1d; final int reconnectAttempts = -1; locator.setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryMultiplier).setReconnectAttempts(reconnectAttempts).setConfirmationWindowSize(1024 * 1024); ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal) createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(ReattachTest.ADDRESS, ReattachTest.ADDRESS, null, false); ClientProducer producer = session.createProducer(ReattachTest.ADDRESS); final int numMessages = 1000; for (int i = 0; i < numMessages; i++) { ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); message.putIntProperty(new SimpleString("count"), i); message.getBodyBuffer().writeString("aardvarks"); producer.send(message); } ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS); InVMConnector.failOnCreateConnection = true; RemotingConnection conn = ((ClientSessionInternal) session).getConnection(); Thread t = new Thread() { @Override public void run() { try { Thread.sleep(retryInterval * 3); } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; } }; t.start(); conn.fail(new ActiveMQNotConnectedException()); session.start(); for (int i = 0; i < numMessages; i++) { ClientMessage message = consumer.receive(500); Assert.assertNotNull(message); Assert.assertEquals("aardvarks", message.getBodyBuffer().readString()); Assert.assertEquals(i, message.getIntProperty("count").intValue()); message.acknowledge(); } ClientMessage message = consumer.receiveImmediate(); Assert.assertNull(message); session.close(); sf.close(); t.join(); }
20. TemporaryQueueTest#testDeleteTemporaryQueueWhenClientCrash()
Project: activemq-artemis
File: TemporaryQueueTest.java
File: TemporaryQueueTest.java
@Test public void testDeleteTemporaryQueueWhenClientCrash() throws Exception { session.close(); sf.close(); final SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); // server must received at least one ping from the client to pass // so that the server connection TTL is configured with the client value final CountDownLatch pingOnServerLatch = new CountDownLatch(1); server.getRemotingService().addIncomingInterceptor(new Interceptor() { @Override public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException { if (packet.getType() == PacketImpl.PING) { pingOnServerLatch.countDown(); } return true; } }); ServerLocator locator = createInVMNonHALocator(); locator.setConnectionTTL(TemporaryQueueTest.CONNECTION_TTL); sf = addSessionFactory(createSessionFactory(locator)); session = sf.createSession(false, true, true); session.createTemporaryQueue(address, queue); assertTrue("server has not received any ping from the client", pingOnServerLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL, TimeUnit.MILLISECONDS)); assertEquals(1, server.getConnectionCount()); RemotingConnection remotingConnection = server.getRemotingService().getConnections().iterator().next(); final CountDownLatch serverCloseLatch = new CountDownLatch(1); remotingConnection.addCloseListener(new CloseListener() { @Override public void connectionClosed() { serverCloseLatch.countDown(); } }); ((ClientSessionInternal) session).getConnection().fail(new ActiveMQInternalErrorException("simulate a client failure")); // let some time for the server to clean the connections assertTrue("server has not closed the connection", serverCloseLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL + 2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS)); // The next getCount will be asynchronously done at the end of failure. We will wait some time until it has reached there. for (long timeout = System.currentTimeMillis() + 5000; timeout > System.currentTimeMillis() && server.getConnectionCount() > 0; ) { Thread.sleep(1); } assertEquals(0, server.getConnectionCount()); session.close(); sf.close(); ServerLocator locator2 = createInVMNonHALocator(); sf = addSessionFactory(createSessionFactory(locator2)); session = sf.createSession(false, true, true); session.start(); ActiveMQAction activeMQAction = new ActiveMQAction() { @Override public void run() throws ActiveMQException { session.createConsumer(queue); } }; ActiveMQTestBase.expectActiveMQException("temp queue must not exist after the server detected the client crash", ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, activeMQAction); session.close(); locator2.close(); }
21. SessionTest#testCloseSessionOnDestroyedConnection()
Project: activemq-artemis
File: SessionTest.java
File: SessionTest.java
// Closing a session if the underlying remoting connection is dead should cleanly // release all resources @Test public void testCloseSessionOnDestroyedConnection() throws Exception { // Make sure we have a short connection TTL so sessions will be quickly closed on the server server.stop(); long ttl = 500; server.getConfiguration().setConnectionTTLOverride(ttl); server.start(); cf = createSessionFactory(locator); ClientSessionInternal clientSession = (ClientSessionInternal) cf.createSession(false, true, true); clientSession.createQueue(queueName, queueName, false); /** keep unused variables in order to maintain references to both objects */ @SuppressWarnings("unused") ClientProducer producer = clientSession.createProducer(); @SuppressWarnings("unused") ClientConsumer consumer = clientSession.createConsumer(queueName); Assert.assertEquals(1, server.getRemotingService().getConnections().size()); RemotingConnection rc = clientSession.getConnection(); rc.fail(new ActiveMQInternalErrorException()); clientSession.close(); long start = System.currentTimeMillis(); while (true) { int cons = server.getRemotingService().getConnections().size(); if (cons == 0) { break; } long now = System.currentTimeMillis(); if (now - start > 10000) { throw new Exception("Timed out waiting for connections to close"); } Thread.sleep(50); } }
22. SessionClosedOnRemotingConnectionFailureTest#testSessionClosedOnRemotingConnectionFailure()
Project: activemq-artemis
File: SessionClosedOnRemotingConnectionFailureTest.java
File: SessionClosedOnRemotingConnectionFailureTest.java
@Test public void testSessionClosedOnRemotingConnectionFailure() throws Exception { ClientSession session = addClientSession(sf.createSession()); session.createQueue("fooaddress", "fooqueue"); ClientProducer prod = session.createProducer("fooaddress"); ClientConsumer cons = session.createConsumer("fooqueue"); session.start(); prod.send(session.createMessage(false)); Assert.assertNotNull(cons.receive()); // Now fail the underlying connection RemotingConnection connection = ((ClientSessionInternal) session).getConnection(); connection.fail(new ActiveMQNotConnectedException()); Assert.assertTrue(session.isClosed()); Assert.assertTrue(prod.isClosed()); Assert.assertTrue(cons.isClosed()); try { prod.send(session.createMessage(false)); Assert.fail("Should throw exception"); } catch (ActiveMQObjectClosedException oce) { } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } try { cons.receive(); Assert.fail("Should throw exception"); } catch (ActiveMQObjectClosedException oce) { } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); }
23. JMSFailoverTest#testManualFailover()
Project: activemq-artemis
File: JMSFailoverTest.java
File: JMSFailoverTest.java
@Test public void testManualFailover() throws Exception { ActiveMQConnectionFactory jbcfLive = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); jbcfLive.setBlockOnNonDurableSend(true); jbcfLive.setBlockOnDurableSend(true); ActiveMQConnectionFactory jbcfBackup = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams)); jbcfBackup.setBlockOnNonDurableSend(true); jbcfBackup.setBlockOnDurableSend(true); jbcfBackup.setInitialConnectAttempts(-1); jbcfBackup.setReconnectAttempts(-1); Connection connLive = jbcfLive.createConnection(); MyExceptionListener listener = new MyExceptionListener(); connLive.setExceptionListener(listener); Session sessLive = connLive.createSession(false, Session.AUTO_ACKNOWLEDGE); ClientSession coreSessionLive = ((ActiveMQSession) sessLive).getCoreSession(); RemotingConnection coreConnLive = ((ClientSessionInternal) coreSessionLive).getConnection(); SimpleString jmsQueueName = new SimpleString(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX + "myqueue"); coreSessionLive.createQueue(jmsQueueName, jmsQueueName, null, true); Queue queue = sessLive.createQueue("myqueue"); final int numMessages = 1000; MessageProducer producerLive = sessLive.createProducer(queue); for (int i = 0; i < numMessages; i++) { TextMessage tm = sessLive.createTextMessage("message" + i); producerLive.send(tm); } // Note we block on P send to make sure all messages get to server before failover JMSUtil.crash(liveServer, coreSessionLive); connLive.close(); // Now recreate on backup Connection connBackup = jbcfBackup.createConnection(); Session sessBackup = connBackup.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumerBackup = sessBackup.createConsumer(queue); connBackup.start(); for (int i = 0; i < numMessages; i++) { TextMessage tm = (TextMessage) consumerBackup.receive(1000); Assert.assertNotNull(tm); Assert.assertEquals("message" + i, tm.getText()); } TextMessage tm = (TextMessage) consumerBackup.receiveNoWait(); Assert.assertNull(tm); connBackup.close(); }
24. BridgeReconnectTest#testDeliveringCountOnBridgeConnectionFailure()
Project: activemq-artemis
File: BridgeReconnectTest.java
File: BridgeReconnectTest.java
@Test public void testDeliveringCountOnBridgeConnectionFailure() throws Exception { server0 = createActiveMQServer(0, isNetty(), server0Params); TransportConfiguration server0tc = new TransportConfiguration(getConnector(), server0Params, "server0tc"); server0.getConfiguration().setConnectorConfigurations(connectors); BridgeConfiguration bridgeConfiguration = createBridgeConfig(); List<BridgeConfiguration> bridgeConfigs = new ArrayList<>(); bridgeConfigs.add(bridgeConfiguration); server0.getConfiguration().setBridgeConfigurations(bridgeConfigs); CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName); List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<>(); queueConfigs0.add(queueConfig0); server0.getConfiguration().setQueueConfigurations(queueConfigs0); CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration().setAddress(forwardAddress).setName(queueName); List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<>(); queueConfigs1.add(queueConfig1); server1.getConfiguration().setQueueConfigurations(queueConfigs1); startServers(); locator = addServerLocator(ActiveMQClient.createServerLocatorWithHA(server0tc, server1tc)); ClientSessionFactory csf0 = locator.createSessionFactory(server0tc); session0 = csf0.createSession(false, true, true); ClientSessionFactory csf1 = locator.createSessionFactory(server1tc); session1 = csf1.createSession(false, true, true); ClientProducer prod0 = session0.createProducer(testAddress); session1.start(); Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName); RemotingConnection forwardingConnection = getForwardingConnection(bridge); InVMConnector.failOnCreateConnection = true; InVMConnector.numberOfFailures = reconnectAttempts - 1; //forwardingConnection.fail(new ActiveMQNotConnectedException()); final int numMessages = NUM_MESSAGES; SimpleString propKey = new SimpleString("propkey"); final Queue queue = (Queue) server0.getPostOffice().getBinding(new SimpleString(queueName)).getBindable(); System.out.println("DeliveringCount: " + queue.getDeliveringCount()); for (int i = 0; i < numMessages; i++) { ClientMessage message = session0.createMessage(false); message.putIntProperty(propKey, i); prod0.send(message); if (i == 50) { forwardingConnection.fail(new ActiveMQException(ActiveMQExceptionType.UNBLOCKED)); } } for (int i = 0; i < 100 && queue.getDeliveringCount() != 0; i++) { Thread.sleep(10); } System.out.println("Check.. DeliveringCount: " + queue.getDeliveringCount()); assertEquals("Delivering count of a source queue should be zero on connection failure", 0, queue.getDeliveringCount()); closeServers(); assertNoMoreConnections(); }
25. ReplicationManager#stop()
Project: activemq-artemis
File: ReplicationManager.java
File: ReplicationManager.java
@Override public void stop() throws Exception { synchronized (this) { if (!started) { logger.trace("Stopping being ignored as it hasn't been started"); return; } } // This is to avoid the write holding a lock while we are trying to close it if (replicatingChannel != null) { replicatingChannel.close(); replicatingChannel.getConnection().getTransportConnection().fireReady(true); } synchronized (replicationLock) { enabled = false; writable.set(true); replicationLock.notifyAll(); clearReplicationTokens(); } RemotingConnection toStop = remotingConnection; if (toStop != null) { toStop.removeFailureListener(failureListener); } remotingConnection = null; started = false; }
26. ClientSessionFactoryImpl#checkCloseConnection()
Project: activemq-artemis
File: ClientSessionFactoryImpl.java
File: ClientSessionFactoryImpl.java
private void checkCloseConnection() { RemotingConnection connectionInUse = connection; Connector connectorInUse = connector; if (connectionInUse != null && sessions.size() == 0) { cancelScheduledTasks(); try { connectionInUse.destroy(); } catch (Throwable ignore) { } connection = null; try { if (connectorInUse != null) { connectorInUse.close(); } } catch (Throwable ignore) { } connector = null; } }