org.apache.activemq.ActiveMQConnectionFactory.createTopicConnection()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(124)

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

ActiveMQConnectionFactory.createTopicConnection介绍

暂无

代码示例

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

newConnection = embeddedConnectionFactory.createTopicConnection();

代码示例来源:origin: stackoverflow.com

final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");    
TopicConnection connection = factory.createTopicConnection();    
Session session = connection.createSession(false,Session.DUPS_OK_ACKNOWLEDGE);

代码示例来源:origin: activequant/aq2o

/**
 * constructs and in-memory active mq transport factory.
 * 
 * @throws Exception
 */
public ActiveMQTransportFactory() throws Exception {
  String conUrl = "vm://localhost";
  log.info("Constructing embedded ActiveMQTransportFactory for " + conUrl);
  connectionFactory = new ActiveMQConnectionFactory(conUrl);
  connectionFactory.setProducerWindowSize(1024000);
  connection = connectionFactory.createTopicConnection();
  connection.start();
  session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

代码示例来源:origin: pierre/meteo

numTries++;
try {
  connection = connectionFactory.createTopicConnection();
  connection.start();
  connected = true;

代码示例来源:origin: activequant/aq2o

/**
 * constructs an activemq transport factory that connects to a specific host
 * and port.
 * 
 * @param host
 *            JMS server host
 * @param port
 *            JMS server port.
 * @throws Exception
 */
public ActiveMQTransportFactory(String host, int port) throws Exception {
  // failover: means that it will automatically reconnect.
  String conUrl = "failover:tcp://" + host + ":" + port
      + "??wireFormat.maxInactivityDuration=0";
  log.info("Constructing ActiveMQTransportFactory for " + conUrl);
  connectionFactory = new ActiveMQConnectionFactory(conUrl);
  connectionFactory.setProducerWindowSize(1024000);
  connectionFactory.setUseAsyncSend(true);
  connectionFactory.setOptimizeAcknowledge(true);
  connection = connectionFactory.createTopicConnection();
  connection.start();
  session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

代码示例来源:origin: activequant/aq2o

/**
 * constructs an activemq transport factory that connects to a specific host
 * and port.
 * 
 * @param host
 *            JMS server host
 * @param port
 *            JMS server port.
 * @throws Exception
 */
public ActiveMQTransportFactory(String host, int port, String username, String password) throws Exception {
  // failover: means that it will automatically reconnect.
  String conUrl = "failover:tcp://" + host + ":" + port
      + "??wireFormat.maxInactivityDuration=0";
  log.info("Constructing ActiveMQTransportFactory for " + conUrl);
  // 
  connectionFactory = new ActiveMQConnectionFactory(conUrl);
  connectionFactory.setUserName(username);
  connectionFactory.setPassword(password);        
  connectionFactory.setProducerWindowSize(1024000);
  connectionFactory.setUseAsyncSend(true);		
  connectionFactory.setOptimizeAcknowledge(true);
  connection = connectionFactory.createTopicConnection(username, password);
  connection.start();
  session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

代码示例来源:origin: pierre/meteo

localTopicConnection = embeddedConnectionFactory.createTopicConnection();

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

newConnection = embeddedConnectionFactory.createTopicConnection();

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

newConnection = embeddedConnectionFactory.createTopicConnection();

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

newConnection = embeddedConnectionFactory.createTopicConnection();

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

@Test
public void testNotificationProperties() throws Exception {
 try (TopicConnection topicConnection = factory.createTopicConnection()) {
   TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
   Topic notificationsTopic = topicSession.createTopic("activemq.notifications");
   TopicSubscriber subscriber = topicSession.createSubscriber(notificationsTopic);
   List<Message> receivedMessages = new CopyOnWriteArrayList<>();
   subscriber.setMessageListener(receivedMessages::add);
   topicConnection.start();
   Wait.waitFor(() -> receivedMessages.size() > 0);
   Assert.assertTrue(receivedMessages.size() > 0);
   for (Message message : receivedMessages) {
    assertNotNull(message);
    assertNotNull(message.getStringProperty("_AMQ_NotifType"));
   }
 }
}

相关文章

微信公众号

最新文章

更多

ActiveMQConnectionFactory类方法