1 Reply Latest reply on Jun 5, 2012 11:15 AM by Gary Tully

    Deleting a single message from topic

    Hans Zimmer Newbie

      Is it possible to delete a single message from a topic? We tried the following approach but this deletes all messages up to the one we want to get rid of:

       

              TopicSession jmsSession = jmsConnection.createTopicSession(false, ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE);

              Topic topic = new ActiveMQTopic(destinationName);

              TopicSubscriber consumer = jmsSession.createDurableSubscriber(topic, subscriptionName);

       

              Message message = consumer.receive(1000l);

              while (null != message) {

                  try {

                      if (messageID.equals(message.getJMSMessageID())) {

                          message.acknowledge();

                      }

                      message = consumer.receive(1000l);

                  }

                  catch (JMSException e) {

                  }

              }

       

      Best regards

      dms