use of com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.MessageProducerBuilder in project pinpoint by naver.
the class ActiveMQClientITBase method testTopicPush.
@Test
public void testTopicPush() throws Exception {
// Given
final String testTopicName = "TestPushTopic";
final ActiveMQTopic testTopic = new ActiveMQTopic(testTopicName);
final String testMessage = "Hello World for Topic!";
final int numMessageConsumers = 2;
final CountDownLatch consumerConsumeLatch = new CountDownLatch(numMessageConsumers);
final Collection<Throwable> consumerThrowables = new CopyOnWriteArrayList<Throwable>();
// create producer
ActiveMQSession producerSession = ActiveMQClientITHelper.createSession(getProducerBrokerName(), getProducerBrokerUrl());
MessageProducer producer = new MessageProducerBuilder(producerSession, testTopic).waitTillStarted().build();
final TextMessage expectedTextMessage = producerSession.createTextMessage(testMessage);
// create 2 consumers
ActiveMQSession consumer1Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
new MessageConsumerBuilder(consumer1Session, testTopic).withMessageListener(new AssertTextMessageListener(consumerConsumeLatch, consumerThrowables, expectedTextMessage)).waitTillStarted().build();
ActiveMQSession consumer2Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
new MessageConsumerBuilder(consumer2Session, testTopic).withMessageListener(new AssertTextMessageListener(consumerConsumeLatch, consumerThrowables, expectedTextMessage)).waitTillStarted().build();
// When
producer.send(expectedTextMessage);
consumerConsumeLatch.await(1L, TimeUnit.SECONDS);
// Then
// Wait till all traces are recorded (consumer traces are recorded from another thread)
awaitAndVerifyTraceCount(3, 1000L);
// trace count : 1
verifyProducerSendEvent(testTopic);
// trace count : 1
verifyConsumerPushEvent(testTopic);
// trace count : 1
verifyConsumerPushEvent(testTopic);
}
use of com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.MessageProducerBuilder in project pinpoint by naver.
the class ActiveMQClientITBase method testTopicPull.
@Test
public void testTopicPull() throws Exception {
// Given
final String testTopicName = "TestPullTopic";
final ActiveMQTopic testTopic = new ActiveMQTopic(testTopicName);
final String testMessage = "Hello World for Topic!";
// create producer
ActiveMQSession producerSession = ActiveMQClientITHelper.createSession(getProducerBrokerName(), getProducerBrokerUrl());
MessageProducer producer = new MessageProducerBuilder(producerSession, testTopic).waitTillStarted().build();
final TextMessage expectedTextMessage = producerSession.createTextMessage(testMessage);
// create 2 consumers
ActiveMQSession consumer1Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
MessageConsumer consumer1 = new MessageConsumerBuilder(consumer1Session, testTopic).waitTillStarted().build();
ActiveMQSession consumer2Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
MessageConsumer consumer2 = new MessageConsumerBuilder(consumer2Session, testTopic).waitTillStarted().build();
// When
producer.send(expectedTextMessage);
Message message1 = consumer1.receive(1000L);
Message message2 = consumer2.receive(1000L);
Assert.assertEquals(testMessage, ((TextMessage) message1).getText());
Assert.assertEquals(testMessage, ((TextMessage) message2).getText());
// Wait till all traces are recorded (consumer traces are recorded from another thread)
awaitAndVerifyTraceCount(9, 5000L);
// trace count : 1
verifyProducerSendEvent(testTopic);
// trace count : 4
verifyConsumerPullEvent(testTopic, consumer1, expectedTextMessage);
// trace count : 4
verifyConsumerPullEvent(testTopic, consumer2, expectedTextMessage);
}
Aggregations