Package org.apache.activemq.spring

Examples of org.apache.activemq.spring.ConsumerBean


    doTestVirtualTopicCreation(10);
  }

  public void doTestVirtualTopicCreation(int total) throws Exception {

        ConsumerBean messageList = new ConsumerBean() {
            public synchronized void onMessage(Message message) {
                super.onMessage(message);
                if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
                    try {
                        message.acknowledge();
                    } catch (JMSException e) {
                        e.printStackTrace();
                    }
                }

            }
        };
        messageList.setVerbose(true);

        String queueAName = getVirtualTopicConsumerName();
        // create consumer 'cluster'
        ActiveMQQueue queue1 = new ActiveMQQueue(queueAName);
        ActiveMQQueue queue2 = new ActiveMQQueue(queueAName);
 
        Session session = createStartAndTrackConnection().createSession(false, ackMode);
        MessageConsumer c1 = session.createConsumer(queue1);
        
        session = createStartAndTrackConnection().createSession(false, ackMode);
        MessageConsumer c2 = session.createConsumer(queue2);

        c1.setMessageListener(messageList);
        c2.setMessageListener(messageList);

        // create topic producer
        Session producerSession = createStartAndTrackConnection().createSession(false, ackMode);
        MessageProducer producer = producerSession.createProducer(new ActiveMQTopic(getVirtualTopicName()));
        assertNotNull(producer);

        for (int i = 0; i < total; i++) {
            producer.send(producerSession.createTextMessage("message: " + i));
        }

        messageList.assertMessagesArrived(total);

        // do twice so we confirm messages do not get redelivered after client acknowledgement
        if( doneTwice == false ) {
            doneTwice = true;
            doTestVirtualTopicCreation(0);
View Full Code Here


        if (connection == null) {
            connection = createConnection();
        }
        connection.start();

        ConsumerBean messageList = new ConsumerBean();
        messageList.setVerbose(true);

        Destination consumeDestination = createConsumeDestination();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        LOG.info("Consuming from: " + consumeDestination);

        MessageConsumer c1 = session.createConsumer(consumeDestination);
        c1.setMessageListener(messageList);

        // create topic producer
        ActiveMQQueue sendDestination = new ActiveMQQueue(getQueueName());
        LOG.info("Sending to: " + sendDestination);

        MessageProducer producer = session.createProducer(sendDestination);
        assertNotNull(producer);

        int total = 10;
        for (int i = 0; i < total; i++) {
            producer.send(session.createTextMessage("message: " + i));
        }

        ///Thread.sleep(1000000);

        messageList.assertMessagesArrived(total);

        LOG.info("Received: " + messageList);
    }
View Full Code Here

        if (connection == null) {
            connection = createConnection();
        }
        connection.start();

        ConsumerBean messageList1 = new ConsumerBean();
        ConsumerBean messageList2 = new ConsumerBean();
        messageList1.setVerbose(true);
        messageList2.setVerbose(true);

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       
        Destination producerDestination = getProducerDestination();
        Destination destination1 = getConsumer1Dsetination();
View Full Code Here

    doTestVirtualTopicCreation(10);
  }

  public void doTestVirtualTopicCreation(int total) throws Exception {

        ConsumerBean messageList = new ConsumerBean() {
            public synchronized void onMessage(Message message) {
                super.onMessage(message);
                if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
                    try {
                        message.acknowledge();
                    } catch (JMSException e) {
                        e.printStackTrace();
                    }
                }

            }
        };
        messageList.setVerbose(true);

        String queueAName = getVirtualTopicConsumerName();
        // create consumer 'cluster'
        ActiveMQQueue queue1 = new ActiveMQQueue(queueAName);
        ActiveMQQueue queue2 = new ActiveMQQueue(queueAName);
 
        Session session = createStartAndTrackConnection().createSession(false, ackMode);
        MessageConsumer c1 = session.createConsumer(queue1);
        
        session = createStartAndTrackConnection().createSession(false, ackMode);
        MessageConsumer c2 = session.createConsumer(queue2);

        c1.setMessageListener(messageList);
        c2.setMessageListener(messageList);

        // create topic producer
        Session producerSession = createStartAndTrackConnection().createSession(false, ackMode);
        MessageProducer producer = producerSession.createProducer(new ActiveMQTopic(getVirtualTopicName()));
        assertNotNull(producer);

        for (int i = 0; i < total; i++) {
            producer.send(producerSession.createTextMessage("message: " + i));
        }

        messageList.assertMessagesArrived(total);

        // do twice so we confirm messages do not get redelivered after client acknowledgement
        if( doneTwice == false ) {
            doneTwice = true;
            doTestVirtualTopicCreation(0);
View Full Code Here

        if (connection == null) {
            connection = createConnection();
        }
        connection.start();

        ConsumerBean messageList = new ConsumerBean();
        messageList.setVerbose(true);
       
        String queueAName = getVirtualTopicConsumerName();
        String queueBName = getVirtualTopicConsumerNameB();
       
        // create consumer 'cluster'
        ActiveMQQueue queue1 = new ActiveMQQueue(queueAName);
        ActiveMQQueue queue2 = new ActiveMQQueue(queueBName);

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer c1 = session.createConsumer(queue1);
        MessageConsumer c2 = session.createConsumer(queue2);

        c1.setMessageListener(messageList);
        c2.setMessageListener(messageList);

        // create topic producer
        ActiveMQTopic topic = new ActiveMQTopic(getVirtualTopicName());
        MessageProducer producer = session.createProducer(topic);
        assertNotNull(producer);

        int total = 100;
        for (int i = 0; i < total; i++) {
            producer.send(session.createTextMessage("message: " + i));
        }
       
        messageList.assertMessagesArrived(total*2);
    }
View Full Code Here

        if (connection == null) {
            connection = createConnection();
        }
        connection.start();

        ConsumerBean messageList = new ConsumerBean();
        messageList.setVerbose(true);

        Destination consumeDestination = createConsumeDestination();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        LOG.info("Consuming from: " + consumeDestination);

        MessageConsumer c1 = session.createConsumer(consumeDestination);
        c1.setMessageListener(messageList);

        // create topic producer
        ActiveMQQueue sendDestination = new ActiveMQQueue(getQueueName());
        LOG.info("Sending to: " + sendDestination);

        MessageProducer producer = session.createProducer(sendDestination);
        assertNotNull(producer);

        int total = 10;
        for (int i = 0; i < total; i++) {
            producer.send(session.createTextMessage("message: " + i));
        }

        ///Thread.sleep(1000000);

        messageList.assertMessagesArrived(total);

        LOG.info("Received: " + messageList);
    }
View Full Code Here

                Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                Queue destination = session.createQueue(getName());

                // consumer
                MessageConsumer consumer = session.createConsumer(destination);
                ConsumerBean listener = new ConsumerBean();
                consumer.setMessageListener(listener);

                // producer
                MessageProducer producer = session.createProducer(destination);
                TextMessage message = session.createTextMessage("Hello World!");
                producer.send(message);
                producer.close();

                listener.assertMessagesArrived(1);

                consumer.close();
                session.close();
                connection.close();
View Full Code Here

        if (connection == null) {
            connection = createConnection();
        }
        connection.start();

        ConsumerBean messageList = new ConsumerBean();
        messageList.setVerbose(true);

        Destination consumeDestination = createConsumeDestination();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        LOG.info("Consuming from: " + consumeDestination);

        MessageConsumer c1 = session.createConsumer(consumeDestination);
        c1.setMessageListener(messageList);

        // create topic producer
        ActiveMQQueue sendDestination = new ActiveMQQueue(getQueueName());
        LOG.info("Sending to: " + sendDestination);

        MessageProducer producer = session.createProducer(sendDestination);
        assertNotNull(producer);

        int total = 10;
        for (int i = 0; i < total; i++) {
            producer.send(session.createTextMessage("message: " + i));
        }

        ///Thread.sleep(1000000);

        messageList.assertMessagesArrived(total);

        LOG.info("Received: " + messageList);
    }
View Full Code Here

        if (connection == null) {
            connection = createConnection();
        }
        connection.start();

        ConsumerBean messageList = new ConsumerBean();
        messageList.setVerbose(true);

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

        Destination destination = new ActiveMQQueue("MyQueue");

        MessageConsumer c1 = session.createConsumer(destination);

        c1.setMessageListener(messageList);

        MessageProducer producer = session.createProducer(destination);
        assertNotNull(producer);

        producer.send(createMessage(session, "invalidBody", "myHeader", "xyz"));
        producer.send(createMessage(session, "validBody", "myHeader", "abc"));

        messageList.assertMessagesArrived(1);
        assertEquals("validBody", ((TextMessage) messageList.flushMessages().get(0)).getText());
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.spring.ConsumerBean

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.