@Override public void stop(StopContext context) { try { factory.close(); } catch (Throwable e) { MessagingLogger.ROOT_LOGGER.failedToDestroy("connection-factory", ""); } }
@Override public void stop(StopContext context) { try { factory.close(); } catch (Throwable e) { MessagingLogger.ROOT_LOGGER.failedToDestroy("connection-factory", ""); } }
public void stop() { if (resourceRecovery != null) { ra.getRecoveryManager().unRegister(resourceRecovery); } if (recoveryConnectionFactory != null) { recoveryConnectionFactory.close(); recoveryConnectionFactory = null; } } }
public void stop() { if (resourceRecovery != null) { ra.getRecoveryManager().unRegister(resourceRecovery); } if (recoveryConnectionFactory != null) { recoveryConnectionFactory.close(); recoveryConnectionFactory = null; } } }
public synchronized void closeConnectionFactory(ConnectionFactoryProperties properties) { Pair<ActiveMQConnectionFactory, AtomicInteger> pair = knownConnectionFactories.get(properties); int references = pair.getB().decrementAndGet(); if (pair.getA() != null && pair.getA() != defaultActiveMQConnectionFactory && references == 0) { knownConnectionFactories.remove(properties).getA().close(); } }
public synchronized void closeConnectionFactory(ConnectionFactoryProperties properties) { Pair<ActiveMQConnectionFactory, AtomicInteger> pair = knownConnectionFactories.get(properties); int references = pair.getB().decrementAndGet(); if (pair.getA() != null && pair.getA() != defaultActiveMQConnectionFactory && references == 0) { knownConnectionFactories.remove(properties).getA().close(); } }
private void internalNoReconnect(String uriToUse, String destinationName) throws Exception { startClient(uriToUse, destinationName, true, false); ConnectionFactory cf = createCF(uriToUse); Connection connection = cf.createConnection(); connection.start(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue(destinationName); MessageConsumer consumer = session.createConsumer(destination); for (int i = 0; i < NUMBER_OF_MESSAGES; i++) { // give more time to receive first message but do not wait so long for last as all message were most likely sent Assert.assertNotNull("consumer.receive(...) returned null for " + i + "th message. Number of expected messages" + " to be received is " + NUMBER_OF_MESSAGES, i == NUMBER_OF_MESSAGES - 1 ? consumer.receive(500) : consumer.receive(5000)); } } finally { connection.stop(); connection.close(); } if (cf instanceof ActiveMQConnectionFactory) { ((ActiveMQConnectionFactory) cf).close(); } }
@Test(timeout = 5000, expected = JMSException.class) public void testDuplicateClientIdSetActiveMQException() throws Exception { ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) cf; Connection con = cf.createConnection(); Connection con2 = cf.createConnection(); try { con.setClientID("valid2"); con2.setClientID("valid2"); fail("Should have failed"); } finally { activeMQConnectionFactory.close(); } }
@Test public void testStaticConnectorLiveConstructor() throws Exception { ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, liveTC); assertFactoryParams(cf, new TransportConfiguration[]{liveTC}, null, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE, ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND, ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS); Connection conn = cf.createConnection(); conn.createSession(false, Session.AUTO_ACKNOWLEDGE); testSettersThrowException(cf); cf.close(); conn.close(); }
@Test(timeout = 5000) public void testDuplicateClientIdSet() throws Exception { ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) cf; Connection con = cf.createConnection(); Connection con2 = cf.createConnection(); try { con.setClientID("valid"); con2.setClientID("valid"); fail("Should have failed for duplicate clientId"); } catch (InvalidClientIDException e) { assertEquals(1, duplicateCount.get()); } finally { activeMQConnectionFactory.close(); } }
@Test public void testSimpleRemoteConnections() throws Exception { for (int i = 0; i < 1000; i++) { TransportConfiguration config = new TransportConfiguration(NETTY_CONNECTOR_FACTORY); ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, config); cf.setInitialConnectAttempts(10); cf.setRetryInterval(100); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("SomeQueue"); MessageProducer producer = session.createProducer(queue); TextMessage msg = session.createTextMessage(); msg.setText("Message " + i); producer.send(msg); producer.close(); session.close(); conn.close(); cf.close(); } }
factory.close();
Thread.sleep(500); Assert.assertEquals(ExampleListener.lastMessage, "Hello world"); ((ActiveMQConnectionFactory) sender.getConnectionFactory()).close(); } finally { try {
private void testThroughNewConnectionFactory(ActiveMQConnectionFactory factory) throws Exception { Connection conn = factory.createConnection(); conn.close(); try (JMSContext ctx = factory.createContext()) { ctx.createProducer().send(ctx.createQueue("queue"), "Test"); } try (JMSContext ctx = factory.createContext()) { Assert.assertNotNull(ctx.createConsumer(ctx.createQueue("queue")).receiveNoWait()); Assert.assertNull(ctx.createConsumer(ctx.createQueue("queue")).receiveNoWait()); } factory.close(); }
factory.close();
factory.close();
qResourceAdapter.getDefaultActiveMQConnectionFactory().close(); qResourceAdapter.stop();