Search in sources :

Example 71 with ActiveMQDestination

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

the class OpenWireProtocolManagerTest method testVtAutoConversion.

@Test
public void testVtAutoConversion() throws Exception {
    underTest = new OpenWireProtocolManager(null, new DummyServer()) {

        @Override
        public ActiveMQDestination virtualTopicConsumerToFQQN(ActiveMQDestination destination) {
            if (lruCacheRef == null) {
                lruCacheRef = vtDestMapCache;
            }
            return super.virtualTopicConsumerToFQQN(destination);
        }
    };
    final int maxCacheSize = 10;
    underTest.setVirtualTopicConsumerLruCacheMax(10);
    underTest.setVirtualTopicConsumerWildcards("A.>;1,B.*.>;2,C.*.*.*.EE;3");
    ActiveMQDestination A = new org.apache.activemq.command.ActiveMQQueue("A.SomeTopic");
    assertEquals(new org.apache.activemq.command.ActiveMQQueue("SomeTopic::A"), underTest.virtualTopicConsumerToFQQN(A));
    ActiveMQDestination B = new org.apache.activemq.command.ActiveMQQueue("B.b.SomeTopic.B");
    assertEquals(new org.apache.activemq.command.ActiveMQQueue("SomeTopic.B::B.b"), underTest.virtualTopicConsumerToFQQN(B));
    ActiveMQDestination C = new org.apache.activemq.command.ActiveMQQueue("C.c.c.SomeTopic.EE");
    assertEquals(new org.apache.activemq.command.ActiveMQQueue("SomeTopic.EE::C.c.c"), underTest.virtualTopicConsumerToFQQN(C));
    for (int i = 0; i < maxCacheSize; i++) {
        ActiveMQDestination identity = new org.apache.activemq.command.ActiveMQQueue("Identity" + i);
        assertEquals(identity, underTest.virtualTopicConsumerToFQQN(identity));
    }
    assertFalse(lruCacheRef.containsKey(A));
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Test(org.junit.Test)

Example 72 with ActiveMQDestination

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

the class BacklogNetworkCrossTalkTest method testProduceConsume.

public void testProduceConsume() throws Exception {
    createBroker("A");
    createBroker("B");
    NetworkConnector nc = bridgeBrokers("A", "B");
    nc.setDuplex(true);
    nc.setDispatchAsync(false);
    startAllBrokers();
    waitForBridgeFormation();
    final int numMessages = 10000;
    // Create queue
    ActiveMQDestination destA = createDestination("AAA", false);
    sendMessages("A", destA, numMessages);
    ActiveMQDestination destB = createDestination("BBB", false);
    sendMessages("B", destB, numMessages);
    // consume across network
    LOG.info("starting consumers..");
    // Setup consumers
    MessageConsumer clientA = createConsumer("A", destB);
    // Setup consumers
    MessageConsumer clientB = createConsumer("B", destA);
    final long maxWait = 5 * 60 * 1000L;
    MessageIdList listA = getConsumerMessages("A", clientA);
    listA.setMaximumDuration(maxWait);
    listA.waitForMessagesToArrive(numMessages);
    MessageIdList listB = getConsumerMessages("B", clientB);
    listB.setMaximumDuration(maxWait);
    listB.waitForMessagesToArrive(numMessages);
    assertEquals("got all on A" + listA.getMessageCount(), numMessages, listA.getMessageCount());
    assertEquals("got all on B" + listB.getMessageCount(), numMessages, listB.getMessageCount());
}
Also used : MessageConsumer(javax.jms.MessageConsumer) NetworkConnector(org.apache.activemq.network.NetworkConnector) MessageIdList(org.apache.activemq.util.MessageIdList) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 73 with ActiveMQDestination

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

the class BatchedMessagePriorityConsumerTest method doTestBatchWithLowPriorityFirst.

public void doTestBatchWithLowPriorityFirst(boolean clientPrioritySupport) throws Exception {
    connection.start();
    connection.setMessagePrioritySupported(clientPrioritySupport);
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    MessageProducer producer = session.createProducer(destination);
    producer.setPriority(0);
    sendMessages(session, producer, 2);
    producer.close();
    MessageProducer producer2 = session.createProducer(destination);
    producer2.setPriority(9);
    sendMessages(session, producer2, 3);
    producer2.close();
    session.close();
    Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED);
    MessageConsumer messageConsumer = consumerSession.createConsumer(destination);
    for (int i = 0; i < 5; i++) {
        Message message = messageConsumer.receive(4000);
        LOG.info("MessageID: " + message.getJMSMessageID());
    }
    consumerSession.commit();
    consumerSession.close();
    // should be nothing left
    consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    messageConsumer = consumerSession.createConsumer(destination);
    assertNull("No message left", messageConsumer.receive(1000));
    consumerSession.close();
}
Also used : MessageConsumer(javax.jms.MessageConsumer) Message(javax.jms.Message) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 74 with ActiveMQDestination

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

the class GeneralInteropTest method sendBytesMessageUsingOpenWire.

private void sendBytesMessageUsingOpenWire(byte[] bytesData) throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    System.out.println("destination: " + destination);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    BytesMessage bytesMessage = session.createBytesMessage();
    bytesMessage.writeBytes(bytesData);
    bytesMessage.writeBoolean(true);
    bytesMessage.writeLong(99999L);
    bytesMessage.writeChar('h');
    bytesMessage.writeInt(987);
    bytesMessage.writeShort((short) 1099);
    bytesMessage.writeUTF("hellobytes");
    producer.send(bytesMessage);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) BytesMessage(javax.jms.BytesMessage) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 75 with ActiveMQDestination

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

the class GeneralInteropTest method sendObjectMessageUsingOpenWire.

private void sendObjectMessageUsingOpenWire(SimpleSerializable obj) throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    System.out.println("destination: " + destination);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    ObjectMessage objectMessage = session.createObjectMessage(obj);
    producer.send(objectMessage);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) 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