org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.close()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.close()方法的一些代码示例,展示了ActiveMQConnectionFactory.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ActiveMQConnectionFactory.close()方法的具体详情如下:
包路径:org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
类名称:ActiveMQConnectionFactory
方法名:close

ActiveMQConnectionFactory.close介绍

暂无

代码示例

代码示例来源:origin: org.wildfly/wildfly-messaging-activemq

@Override
public void stop(StopContext context) {
  try {
    factory.close();
  } catch (Throwable e) {
    MessagingLogger.ROOT_LOGGER.failedToDestroy("connection-factory", "");
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-messaging-activemq

@Override
public void stop(StopContext context) {
  try {
    factory.close();
  } catch (Throwable e) {
    MessagingLogger.ROOT_LOGGER.failedToDestroy("connection-factory", "");
  }
}

代码示例来源:origin: apache/activemq-artemis

public void stop() {
   if (resourceRecovery != null) {
     ra.getRecoveryManager().unRegister(resourceRecovery);
   }

   if (recoveryConnectionFactory != null) {
     recoveryConnectionFactory.close();
     recoveryConnectionFactory = null;
   }
  }
}

代码示例来源:origin: org.apache.activemq/artemis-ra

public void stop() {
   if (resourceRecovery != null) {
     ra.getRecoveryManager().unRegister(resourceRecovery);
   }

   if (recoveryConnectionFactory != null) {
     recoveryConnectionFactory.close();
     recoveryConnectionFactory = null;
   }
  }
}

代码示例来源:origin: org.apache.activemq/artemis-ra

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();
 }
}

代码示例来源:origin: apache/activemq-artemis

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();
 }
}

代码示例来源:origin: apache/activemq-artemis

pair.getA().close();
defaultActiveMQConnectionFactory.close();
recoveryActiveMQConnectionFactory.close();

代码示例来源:origin: org.apache.activemq/artemis-ra

pair.getA().close();
defaultActiveMQConnectionFactory.close();
recoveryActiveMQConnectionFactory.close();

代码示例来源:origin: apache/activemq-artemis

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();
 }
}

代码示例来源:origin: apache/activemq-artemis

@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();
 }
}

代码示例来源:origin: apache/activemq-artemis

@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();
}

代码示例来源:origin: apache/activemq-artemis

@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();
 }
}

代码示例来源:origin: apache/activemq-artemis

@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();
 }
}

代码示例来源:origin: apache/activemq-artemis

factory.close();

代码示例来源:origin: apache/activemq-artemis

Thread.sleep(500);
  Assert.assertEquals(ExampleListener.lastMessage, "Hello world");
  ((ActiveMQConnectionFactory) sender.getConnectionFactory()).close();
} finally {
  try {

代码示例来源:origin: apache/activemq-artemis

conn.close();
   jbcf.close();
jbcf.close();

代码示例来源:origin: apache/activemq-artemis

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();
}

代码示例来源:origin: apache/activemq-artemis

factory.close();

代码示例来源:origin: apache/activemq-artemis

factory.close();

代码示例来源:origin: apache/activemq-artemis

qResourceAdapter.getDefaultActiveMQConnectionFactory().close();
qResourceAdapter.stop();

相关文章

微信公众号

最新文章

更多

ActiveMQConnectionFactory类方法