List of usage examples for javax.jms TextMessage getText
String getText() throws JMSException;
From source file:org.openanzo.combus.realtime.RealtimeUpdatePublisher.java
/** * Handler an update message from the model service * // w w w . ja v a 2 s.c o m * @param context * context of operation * @param session * JMS session message came in over * @param message * JMS Message containing update message stream * @throws AnzoException */ public void handleTransactionMessage(IOperationContext context, Session session, TextMessage message) throws AnzoException { try { // Get the XML data from the message and parse it with the updates parser String results = message.getText(); String version = message.getStringProperty(SerializationConstants.version); if (version != null && currentServerId != null) { if (!version.equals(currentServerId)) { return; } } if (trackers.size() == 0) return; NotificationUpdateHandler handler = new NotificationUpdateHandler(session, version); synchronized (userDestinations) { JSONUpdatesReader.parseUpdateTransactions(results, handler); } } catch (JMSException jmsex) { log.error(LogUtils.COMBUS_MARKER, "Error handling transaction message", jmsex); } }
From source file:org.apache.qpid.systest.management.jmx.QueueManagementTest.java
private void assertMessageIndicesOn(Destination queue, int... expectedIndices) throws Exception { MessageConsumer consumer = _session.createConsumer(queue); for (int i : expectedIndices) { TextMessage message = (TextMessage) consumer.receive(1000); assertNotNull("Expected message with index " + i, message); assertEquals("Expected message with index " + i, i, message.getIntProperty(INDEX)); assertEquals("Expected message content", getContentForMessageNumber(i), message.getText()); }/* w w w . java 2s . c o m*/ assertNull("Unexpected message encountered", consumer.receive(1000)); }
From source file:org.wso2.mb.integration.common.clients.operations.topic.TopicMessageListener.java
public void onMessage(Message message) { messageCount.incrementAndGet();/*from w ww . jav a 2 s . c om*/ localMessageCount++; TextMessage receivedMessage = (TextMessage) message; try { String redelivery = ""; if (message.getJMSRedelivered()) { redelivery = "REDELIVERED"; } else { redelivery = "ORIGINAL"; } if (messageCount.get() % printNumberOfMessagesPer == 0) { log.info("[TOPIC RECEIVE] ThreadID:" + Thread.currentThread().getId() + " topic:" + topicName + " " + "localMessageCount:" + localMessageCount + " totalMessageCount:" + messageCount.get() + " max" + " count:" + stopMessageCount); } if (isToPrintEachMessage) { log.info("(count:" + messageCount.get() + "/threadID:" + Thread.currentThread().getId() + "/topic:" + topicName + ") " + redelivery + " >> " + receivedMessage.getText()); AndesClientUtils.writeToFile(receivedMessage.getText(), fileToWriteReceivedMessages); } if (messageCount.get() % ackAfterEach == 0) { if (topicSession.getAcknowledgeMode() == QueueSession.CLIENT_ACKNOWLEDGE) { receivedMessage.acknowledge(); } } //commit get priority if (messageCount.get() % commitPerMessageCount == 0) { topicSession.commit(); log.info("Committed Topic Session"); } else if (messageCount.get() % rollbackPerMessagecount == 0) { topicSession.rollback(); log.info("Rollbacked Topic Session"); } if (messageCount.get() >= unsubscribeMessageCount) { unsubscribeConsumer(); AndesClientUtils.sleepForInterval(200); } else if (messageCount.get() >= stopMessageCount) { stopMessageListener(); AndesClientUtils.sleepForInterval(200); } if (delayBetweenMessages != 0) { try { Thread.sleep(delayBetweenMessages); } catch (InterruptedException e) { //silently ignore } } } catch (NumberFormatException e) { log.error("Wrong inputs.", e); } catch (JMSException e) { log.error("JMS Exception", e); } }
From source file:org.dawnsci.commandserver.ui.view.StatusQueueView.java
/** * Listens to a topic// w w w . j a v a 2s. co m */ private void createTopicListener(final URI uri) throws Exception { // Use job because connection might timeout. final Job topicJob = new Job("Create topic listener") { @Override protected IStatus run(IProgressMonitor monitor) { try { ConnectionFactory connectionFactory = ConnectionFactoryFacade.createConnectionFactory(uri); StatusQueueView.this.topicConnection = connectionFactory.createConnection(); topicConnection.start(); Session session = topicConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic(getTopicName()); MessageConsumer consumer = session.createConsumer(topic); final Class clazz = getBeanClass(); final ObjectMapper mapper = new ObjectMapper(); MessageListener listener = new MessageListener() { public void onMessage(Message message) { try { if (message instanceof TextMessage) { TextMessage t = (TextMessage) message; final StatusBean bean = mapper.readValue(t.getText(), clazz); mergeBean(bean); } } catch (Exception e) { logger.error("Updating changed bean from topic", e); } } }; consumer.setMessageListener(listener); // Create a listener for administrator broadcast messages. topic = session.createTopic(Constants.ADMIN_MESSAGE_TOPIC); consumer = session.createConsumer(topic); listener = new MessageListener() { public void onMessage(Message message) { try { if (message instanceof TextMessage) { // AdministratorMessage shows a message to the user. final Class msgClass = AdministratorMessage.class; TextMessage t = (TextMessage) message; final AdministratorMessage bean = mapper.readValue(t.getText(), msgClass); getSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openError(getViewSite().getShell(), bean.getTitle(), bean.getMessage()); viewer.refresh(); } }); } } catch (Exception e) { // Not a big deal if they do not get admin messages. } } }; consumer.setMessageListener(listener); return Status.OK_STATUS; } catch (Exception ne) { logger.error("Cannot listen to topic changes because command server is not there", ne); return Status.CANCEL_STATUS; } } }; topicJob.setPriority(Job.INTERACTIVE); topicJob.setSystem(true); topicJob.setUser(false); topicJob.schedule(); }
From source file:org.wso2.mb.integration.tests.amqp.functional.RedeliveryDelayTestCase.java
/** * This test publishes 10 messages and the subscriber rejects the 8th message and then wait for the redelivered * message.//from w w w .j a v a 2s.co m * <p/> * The redelivered message is tested against the same message content with the original message and the timestamps * are also checked against the original message timestamp to make sure that the message was delayed. * * @throws AndesClientConfigurationException * @throws XPathExpressionException * @throws IOException * @throws JMSException * @throws AndesClientException * @throws NamingException */ @Test(groups = { "wso2.mb", "queue" }) public void unacknowledgeMiddleMessageMessageListenerTestCase() throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 10; final List<ImmutablePair<String, Calendar>> receivedMessages = new ArrayList<>(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(), ExchangeType.QUEUE, "unacknowledgeMiddleMessageQueue"); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "unacknowledgeMiddleMessageQueue"); 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") || getMessageList(receivedMessages).contains(textMessage.getText())) { message.acknowledge(); } receivedMessages.add(ImmutablePair.of(textMessage.getText(), Calendar.getInstance())); andesJMSConsumer.getReceivedMessageCount().incrementAndGet(); } catch (JMSException e) { throw new RuntimeException("Exception occurred when receiving messages.", e); } } }); AndesClient publisherClient = new AndesClient(publisherConfig, true); AndesJMSPublisher andesJMSPublisher = publisherClient.getPublishers().get(0); MessageProducer sender = andesJMSPublisher.getSender(); for (int i = 0; i < sendCount; i++) { TextMessage textMessage = andesJMSPublisher.getSession().createTextMessage("#" + Integer.toString(i)); sender.send(textMessage); } AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); log.info("Received Messages : " + getMessageList(receivedMessages)); for (int i = 0; i < sendCount; i++) { Assert.assertEquals(receivedMessages.get(i).getLeft(), "#" + Integer.toString(i), "Invalid messages received. #" + Integer.toString(i) + " expected."); } validateMessageContentAndDelay(receivedMessages, 6, 10, "#7"); Assert.assertEquals(receivedMessages.size(), sendCount + 1, "Message receiving failed."); }
From source file:org.wso2.mb.integration.tests.amqp.functional.RedeliveryDelayTestCase.java
/** * This test publishes 10 messages and the subscriber rejects the 8th message and then wait for the redelivered * message.//from w w w . j av a2 s. co m * <p/> * The redelivered message is tested against the same message content with the original message and the timestamps * are also checked against the original message timestamp to make sure that the message was delayed. * Here message receive method is used instead of the message listener to receive messages. * * @throws AndesClientConfigurationException * @throws XPathExpressionException * @throws IOException * @throws JMSException * @throws AndesClientException * @throws NamingException */ @Test(groups = { "wso2.mb", "queue" }) public void unacknowledgeMiddleMessageMessageReceiverTestCase() throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 10; final List<ImmutablePair<String, Calendar>> receivedMessages = new ArrayList<>(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(), ExchangeType.QUEUE, "unacknowledgeMiddleMessageReceiverQueue"); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "unacknowledgeMiddleMessageReceiverQueue"); publisherConfig.setNumberOfMessagesToSend(sendCount); // Creating clients AndesClient consumerClient = new AndesClient(consumerConfig, true); final AndesJMSConsumer andesJMSConsumer = consumerClient.getConsumers().get(0); final MessageConsumer receiver = andesJMSConsumer.getReceiver(); Thread messageReceivingThread = new Thread() { public void run() { while (receiver != null) { try { TextMessage textMessage = (TextMessage) receiver.receive(); if (!textMessage.getText().equals("#7") || getMessageList(receivedMessages).contains(textMessage.getText())) { textMessage.acknowledge(); } receivedMessages.add(ImmutablePair.of(textMessage.getText(), Calendar.getInstance())); andesJMSConsumer.getReceivedMessageCount().incrementAndGet(); } catch (JMSException e) { throw new RuntimeException("Exception occurred when receiving messages.", e); } } } }; messageReceivingThread.start(); AndesClient publisherClient = new AndesClient(publisherConfig, true); AndesJMSPublisher andesJMSPublisher = publisherClient.getPublishers().get(0); MessageProducer sender = andesJMSPublisher.getSender(); for (int i = 0; i < sendCount; i++) { TextMessage textMessage = andesJMSPublisher.getSession().createTextMessage("#" + Integer.toString(i)); sender.send(textMessage); } AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); log.info("Received Messages : " + getMessageList(receivedMessages)); for (int i = 0; i < sendCount; i++) { Assert.assertEquals(receivedMessages.get(i).getLeft(), "#" + Integer.toString(i), "Invalid messages received. #" + Integer.toString(i) + " expected."); } validateMessageContentAndDelay(receivedMessages, 6, 10, "#7"); Assert.assertEquals(receivedMessages.size(), sendCount + 1, "Message receiving failed."); }
From source file:org.wso2.mb.integration.tests.amqp.functional.RedeliveryDelayTestCase.java
/** * This test publishes 10 messages and the subscriber rejects a message after each 3 received messages and then wait * for the redelivered message./*from w w w .ja v a 2 s . co m*/ * <p/> * The redelivered message is tested against the same message content with the original message and the timestamps * are also checked against the original message timestamp to make sure that the message was delayed. * * @throws AndesClientConfigurationException * @throws XPathExpressionException * @throws IOException * @throws JMSException * @throws AndesClientException * @throws NamingException */ @Test(groups = { "wso2.mb", "queue" }) public void oneByOneUnacknowledgeMessageListenerTestCase() throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 10; final List<ImmutablePair<String, Calendar>> receivedMessages = new ArrayList<>(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(), ExchangeType.QUEUE, "oneByOneUnacknowledgeQueue"); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "oneByOneUnacknowledgeQueue"); 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 || getMessageList(receivedMessages).contains(textMessage.getText())) { message.acknowledge(); } receivedMessages.add(ImmutablePair.of(textMessage.getText(), Calendar.getInstance())); andesJMSConsumer.getReceivedMessageCount().incrementAndGet(); } catch (JMSException e) { throw new RuntimeException("Exception occurred when receiving messages.", e); } } }); AndesClient publisherClient = new AndesClient(publisherConfig, true); AndesJMSPublisher andesJMSPublisher = publisherClient.getPublishers().get(0); MessageProducer sender = andesJMSPublisher.getSender(); for (int i = 0; i < sendCount; i++) { TextMessage textMessage = andesJMSPublisher.getSession().createTextMessage("#" + Integer.toString(i)); sender.send(textMessage); } AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); log.info("Received Messages : " + getMessageList(receivedMessages)); for (int i = 0; i < sendCount; i++) { Assert.assertEquals(receivedMessages.get(i).getLeft(), "#" + Integer.toString(i), "Invalid messages received. #" + Integer.toString(i) + " expected."); } validateMessageContentAndDelay(receivedMessages, 0, 10, "#0"); validateMessageContentAndDelay(receivedMessages, 1, 11, "#3"); validateMessageContentAndDelay(receivedMessages, 2, 12, "#6"); validateMessageContentAndDelay(receivedMessages, 3, 13, "#9"); Assert.assertEquals(receivedMessages.size(), sendCount + 4, "Message receiving failed."); }
From source file:org.wso2.mb.integration.tests.amqp.functional.RedeliveryDelayTestCase.java
/** * This test publishes 10 messages and the subscriber rejects first 4 messages and then wait for the redelivered * message.//from w ww . j a v a 2 s . c om * <p/> * The redelivered message is tested against the same message content with the original message and the timestamps * are also checked against the original message timestamp to make sure that the message was delayed. * * @throws AndesClientConfigurationException * @throws XPathExpressionException * @throws IOException * @throws JMSException * @throws AndesClientException * @throws NamingException */ @Test(groups = { "wso2.mb", "queue" }) public void firstFewUnacknowledgeMessageListenerTestCase() throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 10; final List<ImmutablePair<String, Calendar>> receivedMessages = new ArrayList<>(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(), ExchangeType.QUEUE, "firstFewUnacknowledgeQueue"); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "firstFewUnacknowledgeQueue"); 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 || getMessageList(receivedMessages).contains(textMessage.getText())) { message.acknowledge(); } receivedMessages.add(ImmutablePair.of(textMessage.getText(), Calendar.getInstance())); andesJMSConsumer.getReceivedMessageCount().incrementAndGet(); } catch (JMSException e) { throw new RuntimeException("Exception occurred when receiving messages.", e); } } }); AndesClient publisherClient = new AndesClient(publisherConfig, true); AndesJMSPublisher andesJMSPublisher = publisherClient.getPublishers().get(0); MessageProducer sender = andesJMSPublisher.getSender(); for (int i = 0; i < sendCount; i++) { TextMessage textMessage = andesJMSPublisher.getSession().createTextMessage("#" + Integer.toString(i)); sender.send(textMessage); } AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); log.info("Received Messages : " + getMessageList(receivedMessages)); for (int i = 0; i < sendCount; i++) { Assert.assertEquals(receivedMessages.get(i).getLeft(), "#" + Integer.toString(i), "Invalid messages received. #" + Integer.toString(i) + " expected."); } validateMessageContentAndDelay(receivedMessages, 0, 10, "#0"); validateMessageContentAndDelay(receivedMessages, 1, 11, "#1"); validateMessageContentAndDelay(receivedMessages, 2, 12, "#2"); validateMessageContentAndDelay(receivedMessages, 3, 13, "#3"); Assert.assertEquals(receivedMessages.size(), sendCount + 4, "Message receiving failed."); }
From source file:org.wso2.mb.integration.common.clients.operations.queue.QueueMessageReceiver.java
public void run() { try {// w w w .j a v a2s . com if (useMessageListener) { QueueMessageListener messageListener = new QueueMessageListener(queueConnection, queueSession, queueReceiver, queueName, messageCounter, delayBetweenMessages, printNumberOfMessagesPer, isToPrintEachMessage, fileToWriteReceivedMessages, stopAfter, ackAfterEach, commitAfterEach, rollbackAfterEach); queueReceiver.setMessageListener(messageListener); } else { int localMessageCount = 0; while (true) { Message message = queueReceiver.receive(); if (message != null && message instanceof TextMessage) { messageCounter.incrementAndGet(); localMessageCount++; String redelivery; TextMessage textMessage = (TextMessage) message; if (message.getJMSRedelivered()) { redelivery = "REDELIVERED"; } else { redelivery = "ORIGINAL"; } if (messageCounter.get() % printNumberOfMessagesPer == 0) { log.info("[QUEUE RECEIVE] ThreadID:" + Thread.currentThread().getId() + " queue:" + queueName + " localMessageCount:" + localMessageCount + " totalMessageCount:" + messageCounter.get() + " max count:" + stopAfter); } if (isToPrintEachMessage) { log.info("(count:" + messageCounter.get() + "/threadID:" + Thread.currentThread().getId() + "/queue:" + queueName + ") " + redelivery + " >> " + textMessage.getText()); AndesClientUtils.writeToFile(textMessage.getText(), fileToWriteReceivedMessages); } } if (messageCounter.get() % ackAfterEach == 0) { if (queueSession.getAcknowledgeMode() == QueueSession.CLIENT_ACKNOWLEDGE) { if (message != null) { message.acknowledge(); } } } //commit get priority if (messageCounter.get() % commitAfterEach == 0) { queueSession.commit(); log.info("Committed Queue Session"); } else if (messageCounter.get() % rollbackAfterEach == 0) { queueSession.rollback(); log.info("Rollbacked Queue Session"); } if (messageCounter.get() == stopAfter) { stopListening(); break; } if (delayBetweenMessages != 0) { try { Thread.sleep(delayBetweenMessages); } catch (InterruptedException e) { //silently ignore } } } } } catch (JMSException e) { log.error("Error while listening for messages", e); } }
From source file:org.wso2.mb.integration.tests.amqp.functional.RedeliveryDelayTestCase.java
/** * This test publishes 1000 messages and the subscriber reject each 100th message and then wait for the redelivered * message.//from w w w . j a v a 2s. co m * <p/> * The redelivered message is tested against the same message content with the original message and the timestamps * are also checked against the original message timestamp to make sure that the message was delayed. * * @throws AndesClientConfigurationException * @throws XPathExpressionException * @throws IOException * @throws JMSException * @throws AndesClientException * @throws NamingException */ @Test(groups = { "wso2.mb", "queue" }) public void oneByOneUnacknowledgeMessageListenerForMultipleMessagesTestCase() throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 1000; final List<ImmutablePair<String, Calendar>> receivedMessages = new ArrayList<>(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(), ExchangeType.QUEUE, "oneByOneUnacknowledgeMessageListenerForMultiple"); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "oneByOneUnacknowledgeMessageListenerForMultiple"); 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 || getMessageList(receivedMessages).contains(textMessage.getText())) { message.acknowledge(); } receivedMessages.add(ImmutablePair.of(textMessage.getText(), Calendar.getInstance())); andesJMSConsumer.getReceivedMessageCount().incrementAndGet(); } catch (JMSException e) { throw new RuntimeException("Exception occurred when receiving messages.", e); } } }); AndesClient publisherClient = new AndesClient(publisherConfig, true); AndesJMSPublisher andesJMSPublisher = publisherClient.getPublishers().get(0); MessageProducer sender = andesJMSPublisher.getSender(); for (int i = 0; i < sendCount; i++) { TextMessage textMessage = andesJMSPublisher.getSession().createTextMessage("#" + Integer.toString(i)); sender.send(textMessage); } AndesClientUtils.waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME * 2); log.info("Received Messages : " + getMessageList(receivedMessages)); for (int i = 0; i < sendCount; i++) { Assert.assertEquals(receivedMessages.get(i).getLeft(), "#" + Integer.toString(i), "Invalid messages received. #" + Integer.toString(i) + " expected."); } validateMessageContentAndDelay(receivedMessages, 0, 1000, "#0"); validateMessageContentAndDelay(receivedMessages, 99, 1001, "#100"); validateMessageContentAndDelay(receivedMessages, 199, 1002, "#200"); validateMessageContentAndDelay(receivedMessages, 299, 1003, "#300"); validateMessageContentAndDelay(receivedMessages, 399, 1004, "#400"); validateMessageContentAndDelay(receivedMessages, 499, 1005, "#500"); validateMessageContentAndDelay(receivedMessages, 599, 1006, "#600"); validateMessageContentAndDelay(receivedMessages, 699, 1007, "#700"); validateMessageContentAndDelay(receivedMessages, 799, 1008, "#800"); validateMessageContentAndDelay(receivedMessages, 899, 1009, "#900"); Assert.assertEquals(receivedMessages.size(), sendCount + 10, "Message receiving failed."); }