Example usage for javax.jms Message acknowledge

List of usage examples for javax.jms Message acknowledge

Introduction

In this page you can find the example usage for javax.jms Message acknowledge.

Prototype


void acknowledge() throws JMSException;

Source Link

Document

Acknowledges all consumed messages of the session of this consumed message.

Usage

From source file:org.apache.activemq.artemis.tests.integration.persistence.metrics.JournalPendingMessageTest.java

@Test
public void testDeliveringStats() throws Exception {
    AtomicLong publishedMessageSize = new AtomicLong();

    Connection connection = cf.createConnection();
    connection.start();/* w  w w.j  a v  a2s  .  com*/
    Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    MessageProducer producer = session.createProducer(session.createQueue(defaultQueueName));
    producer.send(session.createTextMessage("test"));

    verifyPendingStats(defaultQueueName, 1, publishedMessageSize.get());
    verifyPendingDurableStats(defaultQueueName, 1, publishedMessageSize.get());
    verifyDeliveringStats(defaultQueueName, 0, 0);

    MessageConsumer consumer = session.createConsumer(session.createQueue(defaultQueueName));
    Message msg = consumer.receive();
    verifyDeliveringStats(defaultQueueName, 1, publishedMessageSize.get());
    msg.acknowledge();

    verifyPendingStats(defaultQueueName, 0, 0);
    verifyPendingDurableStats(defaultQueueName, 0, 0);
    verifyDeliveringStats(defaultQueueName, 0, 0);

    connection.close();
}

From source file:org.wso2.mb.integration.tests.amqp.functional.PerMessageAcknowledgementsTestCase.java

/**
 * This test publishes 1000 messages and the subscriber accepts all message and then wait for the redelivered
 * message.//from  w  ww .  j a  v  a 2  s  . com
 *
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
@Test(groups = { "wso2.mb", "queue" })
public void allAcknowledgeMessageListenerForMultipleMessagesTestCase() throws AndesClientConfigurationException,
        XPathExpressionException, IOException, JMSException, AndesClientException, NamingException {
    long sendCount = 1000;
    final List<String> receivedMessages = new ArrayList<>();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(),
            ExchangeType.QUEUE, "allAcknowledgeMultiplePerAckQueue");
    consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            getAMQPPort(), ExchangeType.QUEUE, "allAcknowledgeMultiplePerAckQueue");
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0);
    MessageConsumer receiver = andesJMSConsumer.getReceiver();
    receiver.setMessageListener(new MessageListener() {
        @Override
        public void onMessage(Message message) {
            try {
                TextMessage textMessage = (TextMessage) message;
                message.acknowledge();
                receivedMessages.add(textMessage.getText());
                andesJMSConsumer.getReceivedMessageCount().incrementAndGet();
            } catch (JMSException e) {
                throw new RuntimeException("Exception occurred when receiving messages.", e);
            }
        }
    });

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    MessageProducer sender = publisherClient.getPublishers().get(0).getSender();
    for (int i = 0; i < sendCount; i++) {
        TextMessage textMessage = publisherClient.getPublishers().get(0).getSession()
                .createTextMessage("#" + Integer.toString(i));
        sender.send(textMessage);
    }

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME * 2);
    log.info("Received Messages : " + receivedMessages);

    for (int i = 0; i < sendCount; i++) {
        Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i),
                "Invalid messages received. #" + Integer.toString(i) + " expected.");
    }

    Assert.assertEquals(receivedMessages.size(), sendCount, "Message receiving failed.");
}

From source file:com.adaptris.core.jms.JmsProducerImpl.java

protected void acknowledge(Message msg) throws JMSException {
    if (msg == null) {
        return;//w  ww.  j  a  va2s.c  o m
    }
    if (configuredAcknowledgeMode() != Session.AUTO_ACKNOWLEDGE && !currentSession().getTransacted()) {
        msg.acknowledge();
    }
}

From source file:org.apache.qpid.disttest.jms.ClientJmsDelegate.java

public void commitOrAcknowledgeMessageIfNecessary(final String sessionName, final Message message) {
    try {// ww  w. jav a2 s.c o  m
        final Session session = _testSessions.get(sessionName);
        if (session.getTransacted()) {
            synchronized (session) {
                session.commit();
            }
        } else if (message != null && session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) {
            message.acknowledge();
        }
    } catch (final JMSException jmse) {
        throw new DistributedTestException("Unable to commit or acknowledge message on session: " + sessionName,
                jmse);
    }
}

From source file:org.wso2.mb.integration.tests.amqp.functional.PerMessageAcknowledgementsTestCase.java

/**
 * This test publishes 10 messages and the subscriber rejects all message and then wait for the redelivered
 * message.//from   w  w  w  . j  av a  2  s  .  c o  m
 *
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
@Test(groups = { "wso2.mb", "queue" })
public void allUnacknowledgeMessageListenerPerAckTestCase() throws AndesClientConfigurationException,
        XPathExpressionException, IOException, JMSException, AndesClientException, NamingException {
    long sendCount = 10;
    final List<String> receivedMessages = new ArrayList<>();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(),
            ExchangeType.QUEUE, "allUnacknowledgePerAckQueue");
    consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            getAMQPPort(), ExchangeType.QUEUE, "allUnacknowledgePerAckQueue");
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0);
    MessageConsumer receiver = andesJMSConsumer.getReceiver();
    receiver.setMessageListener(new MessageListener() {
        @Override
        public void onMessage(Message message) {
            try {
                TextMessage textMessage = (TextMessage) message;
                if (receivedMessages.contains(textMessage.getText())) {
                    message.acknowledge();
                }
                receivedMessages.add(textMessage.getText());
                andesJMSConsumer.getReceivedMessageCount().incrementAndGet();
            } catch (JMSException e) {
                throw new RuntimeException("Exception occurred when receiving messages.", e);
            }
        }
    });

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    MessageProducer sender = publisherClient.getPublishers().get(0).getSender();
    for (int i = 0; i < sendCount; i++) {
        TextMessage textMessage = publisherClient.getPublishers().get(0).getSession()
                .createTextMessage("#" + Integer.toString(i));
        sender.send(textMessage);
    }

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);
    log.info("Received Messages : " + receivedMessages);

    for (int i = 0; i < sendCount * 2; i++) {
        if (i < sendCount) {
            Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i),
                    "Invalid messages received. " + "#" + Integer.toString(i) + "" + " expected.");
        } else {
            Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i - 10),
                    "Invalid messages " + "received. #" + Integer.toString(i - 10) + " expected.");
        }
    }

    Assert.assertEquals(receivedMessages.size(), sendCount * 2, "Message receiving failed.");
}

From source file:org.wso2.mb.integration.tests.amqp.functional.PerMessageAcknowledgementsTestCase.java

/**
 * This test publishes 10 messages and the subscriber rejects the 8th message and then wait for the redelivered
 * message.//from www  .  j a  v a 2 s.c  o  m
 *
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
@Test(groups = { "wso2.mb", "queue" })
public void unacknowledgeMiddleMessageMessageListenerPerAckTestCase() throws AndesClientConfigurationException,
        XPathExpressionException, IOException, JMSException, AndesClientException, NamingException {
    long sendCount = 10;
    final List<String> receivedMessages = new ArrayList<>();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(),
            ExchangeType.QUEUE, "unacknowledgeMiddleMessagePerAckQueue");
    consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            getAMQPPort(), ExchangeType.QUEUE, "unacknowledgeMiddleMessagePerAckQueue");
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0);
    MessageConsumer receiver = andesJMSConsumer.getReceiver();
    receiver.setMessageListener(new MessageListener() {
        @Override
        public void onMessage(Message message) {
            try {
                TextMessage textMessage = (TextMessage) message;
                if (!textMessage.getText().equals("#7") || receivedMessages.contains(textMessage.getText())) {
                    message.acknowledge();
                }
                receivedMessages.add(textMessage.getText());
                andesJMSConsumer.getReceivedMessageCount().incrementAndGet();
            } catch (JMSException e) {
                throw new RuntimeException("Exception occurred when receiving messages.", e);
            }
        }
    });

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    MessageProducer sender = publisherClient.getPublishers().get(0).getSender();
    for (int i = 0; i < sendCount; i++) {
        TextMessage textMessage = publisherClient.getPublishers().get(0).getSession()
                .createTextMessage("#" + Integer.toString(i));
        sender.send(textMessage);
    }

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);
    log.info("Received Messages : " + receivedMessages);

    for (int i = 0; i < sendCount; i++) {
        Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i),
                "Invalid messages received. #" + Integer.toString(i) + " expected.");
    }

    Assert.assertEquals(receivedMessages.get(10), "#7", "Invalid messages received. #7 expected.");

    Assert.assertEquals(receivedMessages.size(), sendCount + 1, "Message receiving failed.");
}

From source file:org.wso2.mb.integration.tests.amqp.functional.PerMessageAcknowledgementsTestCase.java

/**
 * This test publishes 10 messages and the subscriber rejects first 4 messages and then wait for the redelivered
 * message.//from  ww w.  j  av  a2s .c o m
 *
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
@Test(groups = { "wso2.mb", "queue" })
public void firstFewUnacknowledgeMessageListenerPerAckTestCase() throws AndesClientConfigurationException,
        XPathExpressionException, IOException, JMSException, AndesClientException, NamingException {
    long sendCount = 10;
    final List<String> receivedMessages = new ArrayList<>();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(),
            ExchangeType.QUEUE, "firstFewUnacknowledgePerAckQueue");
    consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            getAMQPPort(), ExchangeType.QUEUE, "firstFewUnacknowledgePerAckQueue");
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0);
    MessageConsumer receiver = andesJMSConsumer.getReceiver();
    receiver.setMessageListener(new MessageListener() {
        @Override
        public void onMessage(Message message) {
            try {
                TextMessage textMessage = (TextMessage) message;
                if (Integer.parseInt(textMessage.getText().split("#")[1]) >= 4
                        || receivedMessages.contains(textMessage.getText())) {
                    message.acknowledge();
                }
                receivedMessages.add(textMessage.getText());
                andesJMSConsumer.getReceivedMessageCount().incrementAndGet();
            } catch (JMSException e) {
                throw new RuntimeException("Exception occurred when receiving messages.", e);
            }
        }
    });

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    MessageProducer sender = publisherClient.getPublishers().get(0).getSender();
    for (int i = 0; i < sendCount; i++) {
        TextMessage textMessage = publisherClient.getPublishers().get(0).getSession()
                .createTextMessage("#" + Integer.toString(i));
        sender.send(textMessage);
    }

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);
    log.info("Received Messages : " + receivedMessages);

    for (int i = 0; i < sendCount; i++) {
        Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i),
                "Invalid messages received. #" + Integer.toString(i) + " expected.");
    }

    Assert.assertEquals(receivedMessages.get(10), "#0", "Invalid messages received. #0 expected.");
    Assert.assertEquals(receivedMessages.get(11), "#1", "Invalid messages received. #1 expected.");
    Assert.assertEquals(receivedMessages.get(12), "#2", "Invalid messages received. #2 expected.");
    Assert.assertEquals(receivedMessages.get(13), "#3", "Invalid messages received. #3 expected.");

    Assert.assertEquals(receivedMessages.size(), sendCount + 4, "Message receiving failed.");
}

From source file:org.wso2.mb.integration.tests.amqp.functional.PerMessageAcknowledgementsTestCase.java

/**
 * This test publishes 10 messages and the subscriber rejects a message after each 3 received messages and then wait
 * for the redelivered message.//  w w w .j a va 2  s . c  o  m
 *
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
@Test(groups = { "wso2.mb", "queue" })
public void oneByOneUnacknowledgeMessageListenerPerAckTestCase() throws AndesClientConfigurationException,
        XPathExpressionException, IOException, JMSException, AndesClientException, NamingException {
    long sendCount = 10;
    final List<String> receivedMessages = new ArrayList<>();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(),
            ExchangeType.QUEUE, "oneByOneUnacknowledgePerAckQueue");
    consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            getAMQPPort(), ExchangeType.QUEUE, "oneByOneUnacknowledgePerAckQueue");
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0);
    MessageConsumer receiver = andesJMSConsumer.getReceiver();
    receiver.setMessageListener(new MessageListener() {
        @Override
        public void onMessage(Message message) {
            try {
                TextMessage textMessage = (TextMessage) message;
                if (Integer.parseInt(textMessage.getText().split("#")[1]) % 3 != 0
                        || receivedMessages.contains(textMessage.getText())) {
                    message.acknowledge();
                }
                receivedMessages.add(textMessage.getText());
                andesJMSConsumer.getReceivedMessageCount().incrementAndGet();
            } catch (JMSException e) {
                throw new RuntimeException("Exception occurred when receiving messages.", e);
            }
        }
    });

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    MessageProducer sender = publisherClient.getPublishers().get(0).getSender();
    for (int i = 0; i < sendCount; i++) {
        TextMessage textMessage = publisherClient.getPublishers().get(0).getSession()
                .createTextMessage("#" + Integer.toString(i));
        sender.send(textMessage);
    }

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);
    log.info("Received Messages : " + receivedMessages);

    for (int i = 0; i < sendCount; i++) {
        Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i),
                "Invalid messages received. #" + Integer.toString(i) + " expected.");
    }

    Assert.assertEquals(receivedMessages.get(10), "#0", "Invalid messages received. #0 expected.");
    Assert.assertEquals(receivedMessages.get(11), "#3", "Invalid messages received. #3 expected.");
    Assert.assertEquals(receivedMessages.get(12), "#6", "Invalid messages received. #6 expected.");
    Assert.assertEquals(receivedMessages.get(13), "#9", "Invalid messages received. #9 expected.");

    Assert.assertEquals(receivedMessages.size(), sendCount + 4, "Message receiving failed.");
}

From source file:org.wso2.mb.integration.tests.amqp.functional.PerMessageAcknowledgementsTestCase.java

/**
 * This test publishes 10 messages and the subscriber rejects the first message and then wait for the redelivered
 * message.//from   ww  w  . j a  va2  s .c  o m
 *
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
@Test(groups = { "wso2.mb", "queue" })
public void firstMessageInvalidOnlyPerAckQueueMessageListenerTestCase()
        throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException,
        AndesClientException, NamingException {
    long sendCount = 10;
    final List<String> receivedMessages = new ArrayList<>();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(),
            ExchangeType.QUEUE, "firstMessageInvalidOnlyPerAckQueue");
    consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            getAMQPPort(), ExchangeType.QUEUE, "firstMessageInvalidOnlyPerAckQueue");
    publisherConfig.setNumberOfMessagesToSend(sendCount);
    publisherConfig.setPrintsPerMessageCount(sendCount / 10L);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0);
    MessageConsumer receiver = andesJMSConsumer.getReceiver();
    receiver.setMessageListener(new MessageListener() {
        private boolean receivedFirstMessage = false;

        @Override
        public void onMessage(Message message) {
            try {
                TextMessage textMessage = (TextMessage) message;
                if (!receivedFirstMessage && "#0".equals(textMessage.getText())) {
                    receivedFirstMessage = true;
                } else {
                    message.acknowledge();
                }
                receivedMessages.add(textMessage.getText());
                andesJMSConsumer.getReceivedMessageCount().incrementAndGet();
            } catch (JMSException e) {
                throw new RuntimeException("Exception occurred when receiving messages.", e);
            }
        }
    });

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    MessageProducer sender = publisherClient.getPublishers().get(0).getSender();
    for (int i = 0; i < sendCount; i++) {
        TextMessage textMessage = publisherClient.getPublishers().get(0).getSession()
                .createTextMessage("#" + Integer.toString(i));
        sender.send(textMessage);
    }

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);
    log.info("Received Messages : " + receivedMessages);

    for (int i = 0; i < sendCount; i++) {
        Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i),
                "Invalid messages received. #" + Integer.toString(i) + " expected.");
    }

    Assert.assertEquals(receivedMessages.get(10), "#0", "Invalid messages received. #0 expected.");

    Assert.assertEquals(receivedMessages.size(), sendCount + 1, "Message receiving failed.");
}

From source file:org.wso2.mb.integration.tests.amqp.functional.PerMessageAcknowledgementsTestCase.java

/**
 * This test publishes 1000 messages and the subscriber reject each 100th message and then wait for the redelivered
 * message.//from www.  j a  v a  2  s  . c  o  m
 *
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
@Test(groups = { "wso2.mb", "queue" })
public void oneByOneUnacknowledgeMessageListenerForMultipleMessagesPerAckTestCase()
        throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException,
        AndesClientException, NamingException {
    long sendCount = 1000;
    final List<String> receivedMessages = new ArrayList<>();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(),
            ExchangeType.QUEUE, "oneByOneUnacknowledgeQueuePerAckMultiple");
    consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            getAMQPPort(), ExchangeType.QUEUE, "oneByOneUnacknowledgeQueuePerAckMultiple");
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0);
    MessageConsumer receiver = andesJMSConsumer.getReceiver();
    receiver.setMessageListener(new MessageListener() {
        @Override
        public void onMessage(Message message) {
            try {
                TextMessage textMessage = (TextMessage) message;
                if (Integer.parseInt(textMessage.getText().split("#")[1]) % 100 != 0
                        || receivedMessages.contains(textMessage.getText())) {
                    message.acknowledge();
                }
                receivedMessages.add(textMessage.getText());
                andesJMSConsumer.getReceivedMessageCount().incrementAndGet();
            } catch (JMSException e) {
                throw new RuntimeException("Exception occurred when receiving messages.", e);
            }
        }
    });

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    MessageProducer sender = publisherClient.getPublishers().get(0).getSender();
    for (int i = 0; i < sendCount; i++) {
        TextMessage textMessage = publisherClient.getPublishers().get(0).getSession()
                .createTextMessage("#" + Integer.toString(i));
        sender.send(textMessage);
    }

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME * 2);
    log.info("Received Messages : " + receivedMessages);

    for (int i = 0; i < sendCount; i++) {
        Assert.assertEquals(receivedMessages.get(i), "#" + Integer.toString(i),
                "Invalid messages received. #" + Integer.toString(i) + " expected.");
    }

    Assert.assertEquals(receivedMessages.get(1000), "#0", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1001), "#100", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1002), "#200", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1003), "#300", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1004), "#400", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1005), "#500", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1006), "#600", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1007), "#700", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1008), "#800", "Invalid messages received.");
    Assert.assertEquals(receivedMessages.get(1009), "#900", "Invalid messages received.");

    Assert.assertEquals(receivedMessages.size(), sendCount + 10, "Message receiving failed.");
}