Search in sources :

Example 1 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project pinpoint by naver.

the class ActiveMQClientITBase method testQueuePush.

@Test
public void testQueuePush() throws Exception {
    // Given
    final String testQueueName = "TestPushQueue";
    final ActiveMQQueue testQueue = new ActiveMQQueue(testQueueName);
    final String testMessage = "Hello World for Queue!";
    final CountDownLatch consumerLatch = new CountDownLatch(1);
    final Collection<Throwable> consumerThrowables = new CopyOnWriteArrayList<Throwable>();
    // create producer
    ActiveMQSession producerSession = ActiveMQClientITHelper.createSession(getProducerBrokerName(), getProducerBrokerUrl());
    MessageProducer producer = producerSession.createProducer(testQueue);
    final TextMessage expectedTextMessage = producerSession.createTextMessage(testMessage);
    // create consumer
    ActiveMQSession consumerSession = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
    MessageConsumer consumer = consumerSession.createConsumer(testQueue);
    consumer.setMessageListener(new AssertTextMessageListener(consumerLatch, consumerThrowables, expectedTextMessage));
    // When
    producer.send(expectedTextMessage);
    consumerLatch.await(1L, TimeUnit.SECONDS);
    // Then
    assertNoConsumerError(consumerThrowables);
    // Wait till all traces are recorded (consumer traces are recorded from another thread)
    awaitAndVerifyTraceCount(2, 5000L);
    // trace count : 1
    verifyProducerSendEvent(testQueue);
    // trace count : 1
    verifyConsumerPushEvent(testQueue);
}
Also used : ActiveMQMessageConsumer(org.apache.activemq.ActiveMQMessageConsumer) MessageConsumer(javax.jms.MessageConsumer) ActiveMQSession(org.apache.activemq.ActiveMQSession) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) MessageProducer(javax.jms.MessageProducer) CountDownLatch(java.util.concurrent.CountDownLatch) TextMessage(javax.jms.TextMessage) AssertTextMessageListener(com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.AssertTextMessageListener) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 2 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project pinpoint by naver.

the class ActiveMQClientITBase method testQueuePull.

@Test
public void testQueuePull() throws Exception {
    // Given
    final String testQueueName = "TestPullQueue";
    final ActiveMQQueue testQueue = new ActiveMQQueue(testQueueName);
    final String testMessage = "Hello World for Queue!";
    // create producer
    ActiveMQSession producerSession = ActiveMQClientITHelper.createSession(getProducerBrokerName(), getProducerBrokerUrl());
    MessageProducer producer = producerSession.createProducer(testQueue);
    final TextMessage expectedTextMessage = producerSession.createTextMessage(testMessage);
    // When
    ActiveMQSession consumerSession = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
    MessageConsumer consumer = consumerSession.createConsumer(testQueue);
    // Then
    producer.send(expectedTextMessage);
    Message message = consumer.receive(1000L);
    Assert.assertEquals(testMessage, ((TextMessage) message).getText());
    // Wait till all traces are recorded (consumer traces are recorded from another thread)
    awaitAndVerifyTraceCount(5, 5000L);
    // trace count : 1
    verifyProducerSendEvent(testQueue);
    // trace count : 4
    verifyConsumerPullEvent(testQueue, consumer, expectedTextMessage);
}
Also used : ActiveMQMessageConsumer(org.apache.activemq.ActiveMQMessageConsumer) MessageConsumer(javax.jms.MessageConsumer) ActiveMQSession(org.apache.activemq.ActiveMQSession) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) MessageProducer(javax.jms.MessageProducer) TextMessage(javax.jms.TextMessage) Test(org.junit.Test)

Example 3 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project camel by apache.

the class QueueProducerQoSTest method configureBroker.

@Override
protected void configureBroker(BrokerService broker) throws Exception {
    broker.setUseJmx(true);
    broker.setPersistent(true);
    broker.setDataDirectory("target/activemq-data");
    broker.deleteAllMessages();
    broker.setAdvisorySupport(true);
    broker.addConnector(brokerUri);
    // configure expiration rate
    ActiveMQQueue queueName = new ActiveMQQueue(">");
    PolicyEntry entry = new PolicyEntry();
    entry.setDestination(queueName);
    entry.setExpireMessagesPeriod(1000);
    PolicyMap policyMap = new PolicyMap();
    policyMap.put(queueName, entry);
    broker.setDestinationPolicy(policyMap);
}
Also used : PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry)

Example 4 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project camel by apache.

the class JmsProducerWithJMSHeaderTest method testInOnlyJMSDestination.

@Test
public void testInOnlyJMSDestination() throws Exception {
    Destination queue = new ActiveMQQueue("foo");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.message(0).header("JMSDestination").isNotNull();
    template.sendBodyAndHeader("activemq:queue:bar", "Hello World", JmsConstants.JMS_DESTINATION, queue);
    assertMockEndpointsSatisfied();
    assertEquals("queue://foo", mock.getReceivedExchanges().get(0).getIn().getHeader("JMSDestination", Destination.class).toString());
}
Also used : Destination(javax.jms.Destination) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Test(org.junit.Test)

Example 5 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project camel by apache.

the class JmsProducerWithJMSHeaderTest method testInOutJMSDestination.

@Test
public void testInOutJMSDestination() throws Exception {
    Destination queue = new ActiveMQQueue("reply");
    String reply = (String) template.requestBodyAndHeader("activemq:queue:bar", "Hello World", JmsConstants.JMS_DESTINATION, queue);
    assertEquals("Bye World", reply);
}
Also used : Destination(javax.jms.Destination) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Test(org.junit.Test)

Aggregations

ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)239 Session (javax.jms.Session)81 MessageProducer (javax.jms.MessageProducer)78 MessageConsumer (javax.jms.MessageConsumer)76 TextMessage (javax.jms.TextMessage)73 Test (org.junit.Test)66 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)54 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)44 Message (javax.jms.Message)36 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)33 Connection (javax.jms.Connection)32 Destination (javax.jms.Destination)27 CountDownLatch (java.util.concurrent.CountDownLatch)20 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)18 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)18 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)18 SessionInfo (org.apache.activemq.command.SessionInfo)18 Message (org.apache.activemq.command.Message)17 BasicOpenWireTest (org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest)16 ProducerInfo (org.apache.activemq.command.ProducerInfo)16