Search in sources :

Example 86 with ActiveMQDestination

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

the class ActiveMQOriginalDestinationTest method testActiveMQOriginalDestination.

@Test
public void testActiveMQOriginalDestination() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("activemq:queue:foo", "Hello World");
    assertMockEndpointsSatisfied();
    // consume from bar
    Exchange out = consumer.receive("activemq:queue:bar", 5000);
    assertNotNull(out);
    // and we should have foo as the original destination
    JmsMessage msg = out.getIn(JmsMessage.class);
    Message jms = msg.getJmsMessage();
    ActiveMQMessage amq = assertIsInstanceOf(ActiveMQMessage.class, jms);
    ActiveMQDestination original = amq.getOriginalDestination();
    assertNotNull(original);
    assertEquals("foo", original.getPhysicalName());
    assertEquals("Queue", original.getDestinationTypeAsString());
}
Also used : Exchange(org.apache.camel.Exchange) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) Message(javax.jms.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Test(org.junit.Test)

Example 87 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class JmsQueueWildcardSendReceiveTest method testReceiveWildcardQueueMidAsterisk.

public void testReceiveWildcardQueueMidAsterisk() throws Exception {
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination1 = (ActiveMQDestination) session.createQueue(destination1String);
    ActiveMQDestination destination4 = (ActiveMQDestination) session.createQueue(destination4String);
    Message m = null;
    MessageConsumer consumer = null;
    String text = null;
    sendMessage(session, destination1, destination1String);
    sendMessage(session, destination4, destination4String);
    ActiveMQDestination destination8 = (ActiveMQDestination) session.createQueue("TEST.*.ONE");
    consumer = session.createConsumer(destination8);
    m = consumer.receive(1000);
    assertNotNull(m);
    text = ((TextMessage) m).getText();
    if (!(text.equals(destination1String) || text.equals(destination4String))) {
        fail("unexpected message:" + text);
    }
    m = consumer.receive(1000);
    assertNotNull(m);
    text = ((TextMessage) m).getText();
    if (!(text.equals(destination1String) || text.equals(destination4String))) {
        fail("unexpected message:" + text);
    }
    assertNull(consumer.receiveNoWait());
}
Also used : MessageConsumer(javax.jms.MessageConsumer) TextMessage(javax.jms.TextMessage) Message(javax.jms.Message) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 88 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class JmsMultipleBrokersTestSupport method createDestination.

protected ActiveMQDestination createDestination(String name, boolean topic) throws JMSException {
    Destination dest;
    if (topic) {
        dest = new ActiveMQTopic(name);
        destinations.put(name, dest);
        return (ActiveMQDestination) dest;
    } else {
        dest = new ActiveMQQueue(name);
        destinations.put(name, dest);
        return (ActiveMQDestination) dest;
    }
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 89 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class JmsTopicWildcardSendReceiveTest method testReceiveWildcardTopicMatchSinglePastTheEndWildcard.

public void testReceiveWildcardTopicMatchSinglePastTheEndWildcard() throws Exception {
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination1 = (ActiveMQDestination) session.createTopic("a.>");
    ActiveMQDestination destination2 = (ActiveMQDestination) session.createTopic("a");
    Message m = null;
    MessageConsumer consumer = null;
    String text = null;
    consumer = session.createConsumer(destination1);
    sendMessage(session, destination2, destination3String);
    m = consumer.receive(1000);
    assertNotNull(m);
    text = ((TextMessage) m).getText();
    if (!(text.equals(destination1String) || text.equals(destination3String))) {
        fail("unexpected message:" + text);
    }
    assertNull(consumer.receiveNoWait());
}
Also used : MessageConsumer(javax.jms.MessageConsumer) TextMessage(javax.jms.TextMessage) Message(javax.jms.Message) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 90 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class JmsTopicWildcardSendReceiveTest method testReceiveWildcardTopicEndGreaterThan.

public void testReceiveWildcardTopicEndGreaterThan() throws Exception {
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination1 = (ActiveMQDestination) session.createTopic(destination1String);
    ActiveMQDestination destination2 = (ActiveMQDestination) session.createTopic(destination2String);
    ActiveMQDestination destination3 = (ActiveMQDestination) session.createTopic(destination3String);
    Message m = null;
    MessageConsumer consumer = null;
    String text = null;
    ActiveMQDestination destination7 = (ActiveMQDestination) session.createTopic("TEST.ONE.>");
    consumer = session.createConsumer(destination7);
    sendMessage(session, destination1, destination1String);
    sendMessage(session, destination2, destination2String);
    sendMessage(session, destination3, destination3String);
    m = consumer.receive(1000);
    assertNotNull(m);
    text = ((TextMessage) m).getText();
    if (!(text.equals(destination1String) || text.equals(destination2String) || text.equals(destination3String))) {
        fail("unexpected message:" + text);
    }
    m = consumer.receive(1000);
    assertNotNull(m);
    if (!(text.equals(destination1String) || text.equals(destination2String) || text.equals(destination3String))) {
        fail("unexpected message:" + text);
    }
    m = consumer.receive(1000);
    assertNotNull(m);
    if (!(text.equals(destination1String) || text.equals(destination2String) || text.equals(destination3String))) {
        fail("unexpected message:" + text);
    }
    assertNull(consumer.receiveNoWait());
}
Also used : MessageConsumer(javax.jms.MessageConsumer) TextMessage(javax.jms.TextMessage) Message(javax.jms.Message) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Aggregations

ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)165 Session (javax.jms.Session)62 MessageConsumer (javax.jms.MessageConsumer)49 Message (org.apache.activemq.command.Message)46 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)45 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)44 SessionInfo (org.apache.activemq.command.SessionInfo)44 ProducerInfo (org.apache.activemq.command.ProducerInfo)42 Test (org.junit.Test)41 Message (javax.jms.Message)40 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)40 TextMessage (javax.jms.TextMessage)31 BasicOpenWireTest (org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest)24 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)22 MessageProducer (javax.jms.MessageProducer)18 XATransactionId (org.apache.activemq.command.XATransactionId)15 CountDownLatch (java.util.concurrent.CountDownLatch)14 ActiveMQMessageProducer (org.apache.activemq.ActiveMQMessageProducer)12 MessageAck (org.apache.activemq.command.MessageAck)12 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)11