Java Code Examples for org.apache.activemq.ActiveMQConnectionFactory#createTopicConnection()

The following examples show how to use org.apache.activemq.ActiveMQConnectionFactory#createTopicConnection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DurableSubscriptionHangTestCase.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private Message collectMessagesFromDurableSubscriptionForOneMinute() throws Exception {
   ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
   TopicConnection connection = connectionFactory.createTopicConnection();

   connection.setClientID(clientID);
   TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
   Topic topic = topicSession.createTopic(topicName);
   connection.start();
   TopicSubscriber subscriber = topicSession.createDurableSubscriber(topic, durableSubName);
   LOG.info("About to receive messages");
   Message message = subscriber.receive(120000);
   subscriber.close();
   connection.close();
   LOG.info("collectMessagesFromDurableSubscriptionForOneMinute done");

   return message;
}
 
Example 2
Source File: ActiveMqMessagingAdapterFactory.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private void initialize()
throws JMSException
{
    if(logger.isDebugEnabled())
    {
        logger.debug("Initializing ActiveMQConnectionFactory");
    }
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:"+this.port);
    topicConnection = connectionFactory.createTopicConnection();
    topicConnection.start();
    topicSession = topicConnection.createTopicSession(transacted, Session.AUTO_ACKNOWLEDGE);
    amqTopicSession = new ActiveMQTopicSession(topicSession);
}
 
Example 3
Source File: DurableSubscriptionHangTestCase.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void produceExpiredAndOneNonExpiredMessages() throws JMSException {
   ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
   TopicConnection connection = connectionFactory.createTopicConnection();
   TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
   Topic topic = session.createTopic(topicName);
   MessageProducer producer = session.createProducer(topic);
   producer.setTimeToLive(TimeUnit.SECONDS.toMillis(1));
   for (int i = 0; i < 40000; i++) {
      sendRandomMessage(session, producer);
   }
   producer.setTimeToLive(TimeUnit.DAYS.toMillis(1));
   sendRandomMessage(session, producer);
   connection.close();
   LOG.info("produceExpiredAndOneNonExpiredMessages done");
}
 
Example 4
Source File: DurableSubscriptionHangTestCase.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void registerDurableSubscription() throws JMSException {
   ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
   TopicConnection connection = connectionFactory.createTopicConnection();
   connection.setClientID(clientID);
   TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
   Topic topic = topicSession.createTopic(topicName);
   TopicSubscriber durableSubscriber = topicSession.createDurableSubscriber(topic, durableSubName);
   connection.start();
   durableSubscriber.close();
   connection.close();
   LOG.info("Durable Sub Registered");
}