List of usage examples for javax.jms Message acknowledge
void acknowledge() throws JMSException;
From source file:org.audit4j.core.AsyncAuditEngine.java
/** * Listen.//from ww w .j a v a 2 s. c om */ public void listen() { try { final MessageConsumer consumer = session.createConsumer(destination); final MessageListener listener = new MessageListener() { @Override public void onMessage(final Message message) { try { final ObjectMessage objectMessage = (ObjectMessage) message; final Object object = objectMessage.getObject(); if (object instanceof AnnotationAuditEvent) { AsynchronousAnnotationProcessor processor = AsynchronousAnnotationProcessor .getInstance(); processor.process((AnnotationAuditEvent) object); } else if (object instanceof AsyncCallAuditDto) { } } catch (final JMSException e) { e.printStackTrace(); } try { message.acknowledge(); } catch (final JMSException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Received Message"); } }; consumer.setMessageListener(listener); } catch (final Exception e) { System.out.println("Caught: " + e); e.printStackTrace(); } }
From source file:org.springframework.jms.core.JmsTemplate.java
protected Message doReceive(Session session, Destination destination) throws JMSException { MessageConsumer consumer = createConsumer(session, destination); try {//from ww w . ja va2 s . c om // use transaction timeout if available long timeout = getReceiveTimeout(); ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager .getResource(getConnectionFactory()); if (conHolder != null && conHolder.hasTimeout()) { timeout = conHolder.getTimeToLiveInMillis(); } Message message = (timeout >= 0) ? consumer.receive(timeout) : consumer.receive(); if (session.getTransacted()) { if (conHolder == null) { // transacted session created by this template -> commit session.commit(); } } else if (message != null && isClientAcknowledge(session)) { message.acknowledge(); } return message; } finally { JmsUtils.closeMessageConsumer(consumer); } }
From source file:tools.ConsumerTool.java
public void handleMessage(Session session, Message message, int perConsumerReceivedMessages) { try {/* w ww . jav a2 s . c om*/ if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); LOGGER.info("Received text message: " + text); } else { LOGGER.info("Received message: " + message); } if (perMessageSleepMS > 0) { try { Thread.sleep(perMessageSleepMS); } catch (InterruptedException e) { LOGGER.debug("Interrupted while sleeping", e); } } if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) { if (perConsumerReceivedMessages % batchSize == 0) { message.acknowledge(); } } if (transacted) { if (perConsumerReceivedMessages % batchSize == 0) { session.commit(); } } } catch (JMSException e) { LOGGER.error("JMSException handling message: " + e.getMessage(), e); } }
From source file:org.wso2.mb.integration.tests.amqp.functional.RedeliveryDelayTestCase.java
/** * This test publishes 10 messages and the subscriber rejects all message and then wait for the redelivered * message.//w w w . j av a 2 s . c o 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 allUnacknowledgeMessageListenerTestCase() throws AndesClientConfigurationException, XPathExpressionException, IOException, JMSException, AndesClientException, NamingException { int sendCount = 10; final List<ImmutablePair<String, Calendar>> receivedMessages = new ArrayList<>(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(), ExchangeType.QUEUE, "multipleUnacknowledgeQueue"); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "multipleUnacknowledgeQueue"); 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 (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 * 2; i++) { if (i < sendCount) { Assert.assertEquals(receivedMessages.get(i).getLeft(), "#" + Integer.toString(i), "Invalid messages received. #" + Integer.toString(i) + " expected."); } else { validateMessageContentAndDelay(receivedMessages, i - sendCount, i, "#" + Integer.toString(i - sendCount)); } } Assert.assertEquals(receivedMessages.size(), sendCount * 2, "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 ww . 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 first message and then wait for the redelivered * message./*from ww w . jav a 2 s .c o 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 firstMessageInvalidOnlyQueueMessageListenerTestCase() 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, "firstMessageInvalidOnlyQueue"); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.PER_MESSAGE_ACKNOWLEDGE); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "firstMessageInvalidOnlyQueue"); 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(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"); 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 first 4 messages and then wait for the redelivered * message./*from ww w . j a v a2s . c o 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 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.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 ww . j a v a 2s . 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 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 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 .c o 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."); }
From source file:org.codehaus.stomp.jms.StompSubscription.java
public void onMessage(Message message) { String destinationName = (String) headers.get(Stomp.Headers.Subscribe.DESTINATION); try {//from w ww . ja v a2 s .co m log.debug("Received from HQ: " + message.getJMSMessageID()); log.debug("received: " + destinationName + " for: " + message.getObjectProperty("messagereplyto")); } catch (JMSException e) { log.warn("received: " + destinationName + " with trouble getting the message properties"); } if (message != null) { log.debug("Locking session to send a message"); // Lock the session so that the connection cannot be started before // the acknowledge is done synchronized (session) { // Send the message to the server log.debug("Sending message: " + session); try { session.sendToStomp(message, subscriptionId); try { session.wait(); } catch (InterruptedException e) { log.error("Could not wait to be woken", e); } // Acknowledge the message for this connection as we know // the server has received it now try { log.debug("Acking message: " + message.getJMSMessageID()); message.acknowledge(); log.debug("Acked message: " + message.getJMSMessageID()); } catch (JMSException e) { log.error("Could not acknowledge the message: " + e, e); } } catch (IOException e) { log.warn("Could not send to stomp: " + e, e); try { session.recover(); } catch (JMSException e1) { log.fatal("Could not recover the session, possible lost message: " + e, e); } } catch (JMSException e) { log.warn("Could not convert message to send to stomp: " + e, e); try { session.recover(); } catch (JMSException e1) { log.fatal("Could not recover the session, possible lost message: " + e, e); } } } } }