Search in sources :

Example 91 with ActiveMQDestination

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

the class JmsTopicWildcardSendReceiveTest method testReceiveWildcardTopicMatchDoubleWildcard.

public void testReceiveWildcardTopicMatchDoubleWildcard() throws Exception {
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination1 = (ActiveMQDestination) session.createTopic("a.*.>.>");
    ActiveMQDestination destination2 = (ActiveMQDestination) session.createTopic("a.b");
    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 92 with ActiveMQDestination

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

the class NetworkBrokerDetachTest method testNetworkedBrokerDetach.

@Test
public void testNetworkedBrokerDetach() throws Exception {
    LOG.info("Creating Consumer on the networked broker ...");
    // Create a consumer on the networked broker
    ConnectionFactory consFactory = createConnectionFactory(networkedBroker);
    Connection consConn = consFactory.createConnection();
    Session consSession = consConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = (ActiveMQDestination) consSession.createQueue(DESTINATION_NAME);
    for (int i = 0; i < NUM_CONSUMERS; i++) {
        consSession.createConsumer(destination);
    }
    assertTrue("got expected consumer count from mbean within time limit", verifyConsumerCount(1, destination, broker));
    LOG.info("Stopping Consumer on the networked broker ...");
    // Closing the connection will also close the consumer
    consConn.close();
    // We should have 0 consumer for the queue on the local broker
    assertTrue("got expected 0 count from mbean within time limit", verifyConsumerCount(0, destination, broker));
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) Connection(javax.jms.Connection) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Test(org.junit.Test)

Example 93 with ActiveMQDestination

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

the class DemandForwardingBridgeFilterTest method assertReceiveNoMessageOn.

private void assertReceiveNoMessageOn(String destinationName, byte destinationType) throws Exception, InterruptedException {
    ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, destinationType);
    // Send the message to the local broker.
    producerConnection.send(createMessage(producerInfo, destination, destinationType));
    // Make sure the message was delivered via the remote.
    Message m = createConsumerAndReceiveMessage(destination);
    assertNull(m);
}
Also used : Message(org.apache.activemq.command.Message) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 94 with ActiveMQDestination

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

the class DemandForwardingBridgeFilterTest method assertReceiveMessageOn.

private void assertReceiveMessageOn(String destinationName, byte destinationType) throws Exception, InterruptedException {
    ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, destinationType);
    // Send the message to the local broker.
    producerConnection.send(createMessage(producerInfo, destination, destinationType));
    // Make sure the message was delivered via the remote.
    Message m = createConsumerAndReceiveMessage(destination);
    assertNotNull(m);
}
Also used : Message(org.apache.activemq.command.Message) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 95 with ActiveMQDestination

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

the class ObjectFactoryTest method testDestination.

public void testDestination() throws Exception {
    // Create sample destination
    ActiveMQDestination dest = new ActiveMQQueue();
    dest.setPhysicalName("TEST.FOO");
    // Create reference
    Reference ref = JNDIReferenceFactory.createReference(dest.getClass().getName(), dest);
    // Get object created based on reference
    ActiveMQDestination temp;
    JNDIReferenceFactory refFactory = new JNDIReferenceFactory();
    temp = (ActiveMQDestination) refFactory.getObjectInstance(ref, null, null, null);
    // Check settings
    assertEquals(dest.getPhysicalName(), temp.getPhysicalName());
}
Also used : Reference(javax.naming.Reference) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) 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