Search in sources :

Example 6 with ActiveMQQueue

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

the class ActiveMqMessagingService method removeQueue.

public void removeQueue(String queueName) {
    try {
        ActiveMQQueue destination = new ActiveMQQueue(queueName);
        ConnectionContext connectionContext = BrokerSupport.getConnectionContext(broker.getBroker());
        Destination brokerDestination = broker.getDestination(destination);
        List<Subscription> consumers = brokerDestination.getConsumers();
        for (Subscription consumer : consumers) {
            consumer.remove(connectionContext, brokerDestination);
            brokerDestination.removeSubscription(connectionContext, consumer, 0);
        }
        broker.getBroker().removeDestination(connectionContext, destination, 1000);
        broker.removeDestination(destination);
    } catch (Exception e) {
        throw bomb(e);
    }
}
Also used : Destination(org.apache.activemq.broker.region.Destination) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) ConnectionContext(org.apache.activemq.broker.ConnectionContext) Subscription(org.apache.activemq.broker.region.Subscription) JMSException(javax.jms.JMSException)

Example 7 with ActiveMQQueue

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

the class IgniteJmsStreamerTest method testQueueFromName.

/**
     * @throws Exception If failed.
     */
public void testQueueFromName() throws Exception {
    Destination dest = new ActiveMQQueue(QUEUE_NAME);
    // produce messages into the queue
    produceObjectMessages(dest, false);
    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<ObjectMessage, String, String> jmsStreamer = newJmsStreamer(ObjectMessage.class, dataStreamer);
        jmsStreamer.setDestinationType(Queue.class);
        jmsStreamer.setDestinationName(QUEUE_NAME);
        // 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) ObjectMessage(javax.jms.ObjectMessage) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 8 with ActiveMQQueue

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

the class JmsEndpointWithCustomDestinationTest method testMessageSentToCustomEndpoint.

@Test
public void testMessageSentToCustomEndpoint() throws Exception {
    ActiveMQQueue jmsQueue = context.getRegistry().lookupByNameAndType("jmsQueue", ActiveMQQueue.class);
    assertNotNull("jmsQueue", jmsQueue);
    assertEquals("jmsqueue.getPhysicalName()", "Test.Camel.CustomEndpoint", jmsQueue.getPhysicalName());
    getMockEndpoint("mock:result").expectedBodiesReceived(expectedBody);
    template.sendBody("direct:start", expectedBody);
    assertMockEndpointsSatisfied();
}
Also used : ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Test(org.junit.Test)

Example 9 with ActiveMQQueue

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

the class JmsRequestReplyManualReplyTest method testManualRequestReply.

@Test
public void testManualRequestReply() throws Exception {
    context.start();
    // send using pure JMS API to set a custom JMSReplyTo
    jms.send(new ActiveMQQueue("foo"), new MessageCreator() {

        public Message createMessage(Session session) throws JMSException {
            TextMessage msg = session.createTextMessage("Hello World");
            msg.setJMSReplyTo(new ActiveMQQueue("bar"));
            return msg;
        }
    });
    assertTrue(latch.await(5, TimeUnit.SECONDS));
    String reply = consumer.receiveBody(tempName, 5000, String.class);
    assertEquals("Bye World", reply);
}
Also used : TextMessage(javax.jms.TextMessage) Message(javax.jms.Message) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) JMSException(javax.jms.JMSException) MessageCreator(org.springframework.jms.core.MessageCreator) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session) Test(org.junit.Test)

Example 10 with ActiveMQQueue

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

the class IgniteJmsStreamerTest method testInsertMultipleCacheEntriesFromOneMessage.

/**
     * @throws Exception If failed.
     */
public void testInsertMultipleCacheEntriesFromOneMessage() throws Exception {
    Destination dest = new ActiveMQQueue(QUEUE_NAME);
    // produce A SINGLE MESSAGE, containing all data, into the queue
    produceStringMessages(dest, true);
    try (IgniteDataStreamer<String, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
        JmsStreamer<TextMessage, String, String> jmsStreamer = newJmsStreamer(TextMessage.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();
        // all cache PUT events received in 10 seconds
        latch.await(10, TimeUnit.SECONDS);
        assertAllCacheEntriesLoaded();
        jmsStreamer.stop();
    }
}
Also used : Destination(javax.jms.Destination) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) CountDownLatch(java.util.concurrent.CountDownLatch) TextMessage(javax.jms.TextMessage)

Aggregations

ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)16 Destination (javax.jms.Destination)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 TextMessage (javax.jms.TextMessage)8 Test (org.junit.Test)6 ObjectMessage (javax.jms.ObjectMessage)3 DestinationStatistics (org.apache.activemq.broker.region.DestinationStatistics)3 JMSException (javax.jms.JMSException)2 Message (javax.jms.Message)2 MessageConsumer (javax.jms.MessageConsumer)2 MessageProducer (javax.jms.MessageProducer)2 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)2 ActiveMQSession (org.apache.activemq.ActiveMQSession)2 Subscription (org.apache.activemq.broker.region.Subscription)2 AssertTextMessageListener (com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.AssertTextMessageListener)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Session (javax.jms.Session)1 ConnectionContext (org.apache.activemq.broker.ConnectionContext)1 Destination (org.apache.activemq.broker.region.Destination)1 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)1