Search in sources :

Example 6 with ActiveMQTopic

use of org.apache.activemq.command.ActiveMQTopic in project ignite by apache.

the class IgniteJmsStreamerTest method testDurableSubscriberStartStopStart.

/**
     * @throws Exception If failed.
     */
public void testDurableSubscriberStartStopStart() throws Exception {
    Destination dest = new ActiveMQTopic(TOPIC_NAME);
    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<TextMessage, String, String> jmsStreamer = newJmsStreamer(TextMessage.class, dataStreamer);
        jmsStreamer.setDestination(dest);
        jmsStreamer.setDurableSubscription(true);
        jmsStreamer.setClientId(Long.toString(System.currentTimeMillis()));
        jmsStreamer.setDurableSubscriptionName("ignite-test-durable");
        // we start the streamer so that the durable subscriber registers itself
        jmsStreamer.start();
        // we stop it immediately
        jmsStreamer.stop();
        // we assert that there are no clients of the broker (to make sure we disconnected properly)
        assertEquals(0, broker.getCurrentConnections());
        // we send messages while we're still away
        produceStringMessages(dest, false);
        // subscribe to cache PUT events and return a countdown latch starting at CACHE_ENTRY_COUNT
        CountDownLatch latch = subscribeToPutEvents(CACHE_ENTRY_COUNT);
        jmsStreamer.start();
        // all cache PUT events received in 10 seconds
        latch.await(10, TimeUnit.SECONDS);
        assertAllCacheEntriesLoaded();
        jmsStreamer.stop();
    }
}
Also used : Destination(javax.jms.Destination) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) CountDownLatch(java.util.concurrent.CountDownLatch) TextMessage(javax.jms.TextMessage)

Example 7 with ActiveMQTopic

use of org.apache.activemq.command.ActiveMQTopic in project ignite by apache.

the class IgniteJmsStreamerTest method testTopicFromExplicitDestination.

/**
     * @throws Exception If failed.
     */
public void testTopicFromExplicitDestination() throws JMSException, InterruptedException {
    Destination dest = new ActiveMQTopic(TOPIC_NAME);
    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<ObjectMessage, String, String> jmsStreamer = newJmsStreamer(ObjectMessage.class, dataStreamer);
        jmsStreamer.setDestination(dest);
        // subscribe to cache PUT events and return a countdown latch starting at CACHE_ENTRY_COUNT
        CountDownLatch latch = subscribeToPutEvents(CACHE_ENTRY_COUNT);
        jmsStreamer.start();
        // produce messages
        produceObjectMessages(dest, false);
        // all cache PUT events received in 10 seconds
        latch.await(10, TimeUnit.SECONDS);
        assertAllCacheEntriesLoaded();
        jmsStreamer.stop();
    }
}
Also used : Destination(javax.jms.Destination) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ObjectMessage(javax.jms.ObjectMessage) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 8 with ActiveMQTopic

use of org.apache.activemq.command.ActiveMQTopic in project ignite by apache.

the class IgniteMqttStreamerTest method testMultipleTopics_MultipleQoS_OneEntryPerMessage.

/**
     * @throws Exception If failed.
     */
public void testMultipleTopics_MultipleQoS_OneEntryPerMessage() throws Exception {
    // configure streamer
    streamer.setSingleTupleExtractor(singleTupleExtractor());
    streamer.setTopics(MULTIPLE_TOPIC_NAMES);
    streamer.setQualitiesOfService(Arrays.asList(1, 1, 1, 1));
    // subscribe to cache PUT events
    CountDownLatch latch = subscribeToPutEvents(50);
    // action time
    streamer.start();
    // send messages
    sendMessages(MULTIPLE_TOPIC_NAMES, 0, 50, false);
    // assertions
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    assertCacheEntriesLoaded(50);
    assertTrue(broker.getBroker().getDestinationMap().size() >= 4);
    assertTrue(broker.getBroker().getDestinationMap().containsKey(new ActiveMQTopic("def")));
    assertTrue(broker.getBroker().getDestinationMap().containsKey(new ActiveMQTopic("ghi")));
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 Destination (javax.jms.Destination)3 TextMessage (javax.jms.TextMessage)3 MessageConsumerBuilder (com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.MessageConsumerBuilder)2 MessageProducerBuilder (com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.MessageProducerBuilder)2 MessageProducer (javax.jms.MessageProducer)2 ObjectMessage (javax.jms.ObjectMessage)2 ActiveMQSession (org.apache.activemq.ActiveMQSession)2 Test (org.junit.Test)2 AssertTextMessageListener (com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.AssertTextMessageListener)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Message (javax.jms.Message)1 MessageConsumer (javax.jms.MessageConsumer)1 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)1