Package org.apache.activemq.util

Examples of org.apache.activemq.util.MessageIdList


            return createConsumer(dest, s);
        }

        public MessageConsumer createConsumer(Destination dest, Session sess) throws Exception {
            MessageConsumer client = sess.createConsumer(dest);
            MessageIdList messageIdList = new MessageIdList();
            messageIdList.setParent(allMessages);
            client.setMessageListener(messageIdList);
            consumers.put(client, messageIdList);

            return client;
        }
View Full Code Here


            return createDurableSubscriber(dest, s, name);
        }

        public MessageConsumer createDurableSubscriber(Topic dest, Session sess, String name) throws Exception {
            MessageConsumer client = sess.createDurableSubscriber((Topic)dest, name);
            MessageIdList messageIdList = new MessageIdList();
            messageIdList.setParent(allMessages);
            client.setMessageListener(messageIdList);
            consumers.put(client, messageIdList);

            return client;
        }
View Full Code Here

        return conn;
    }

    protected int receiveMessages(Connection conn, Destination dest, int waitTime) throws JMSException, InterruptedException {
        conn.start();
        MessageIdList list = new MessageIdList();
        Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer = sess.createConsumer(dest);
        consumer.setMessageListener(list);

        if (waitTime > 0) {
            Thread.sleep(waitTime);
        } else {
            list.waitForMessagesToArrive(MESSAGE_COUNT);
        }

        conn.close();

        return list.getMessageCount();
    }
View Full Code Here

        // Send messages
        sendMessages("BrokerA", dest, MESSAGE_COUNT);

        // Get message count
        MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
        MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);

        msgsA.waitForMessagesToArrive(MESSAGE_COUNT);
        msgsB.waitForMessagesToArrive(MESSAGE_COUNT);

        assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());
        assertEquals(MESSAGE_COUNT, msgsB.getMessageCount());

        // Check that 10 message dispatch commands are send over the network
        assertEquals(MESSAGE_COUNT, msgDispatchCount.get());
    }
View Full Code Here

        // Send messages
        sendMessages("BrokerA", dest, MESSAGE_COUNT);

        // Get message count
        MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);

        msgsA.waitForMessagesToArrive(MESSAGE_COUNT);

        assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());

        // Check that no message dispatch commands are send over the network
        assertEquals(0, msgDispatchCount.get());
    }
View Full Code Here

    }

    public void assertOneConsumerReceivedAllMessages(int messageCount) throws Exception {
        boolean found = false;
        for (Iterator i=consumers.keySet().iterator(); i.hasNext();) {
            MessageIdList messageIdList = (MessageIdList)consumers.get(i.next());
            int count = messageIdList.getMessageCount();
            if (count > 0) {
                if (found) {
                    fail("No other consumers should have received any messages");
                } else {
                    assertEquals("Consumer should have received all messages.", messageCount, count);
View Full Code Here

        connection = createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        connection.start();

        MessageConsumer consumer = session.createConsumer(destination);
        MessageIdList listener = new MessageIdList();
        listener.setVerbose(true);
        consumer.setMessageListener(listener);

        MessageProducer producer = session.createProducer(destination);
        int updateMessageCount = messageCount - DummyMessageQuery.messageCount;
        for (int i = 0; i < updateMessageCount; i++) {
            TextMessage message = session.createTextMessage("Update Message: " + i + " sent at: " + new Date());
            producer.send(message);
        }
        producer.close();
        log.info("Sent: " + updateMessageCount + " update messages");

        listener.assertMessagesReceived(messageCount);
    }
View Full Code Here

            return;
        }

        // Get basis of order
        Iterator i = consumers.keySet().iterator();
        MessageIdList messageOrder = (MessageIdList)consumers.get(i.next());

        for (;i.hasNext();) {
            MessageIdList messageIdList = (MessageIdList)consumers.get(i.next());
            assertTrue("Messages are not ordered.", messageOrder.equals(messageIdList));
        }
    }
View Full Code Here

        connection = createConnection();
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        MessageConsumer consumer = createConsumer();
        MessageIdList listener = new MessageIdList();
        consumer.setMessageListener(listener);
        listener.waitForMessagesToArrive(messageCount);
        listener.assertMessagesReceived(messageCount);

    }
View Full Code Here

        // Let's try to wait for any messages. Should be none.
        Thread.sleep(1000);

        // Get message count
        MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
        assertEquals(0, msgsC.getMessageCount());
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.util.MessageIdList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.