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