I just started learning about JMS Queues and wanted how I can remove a message from the queue given the JMSMessageID. I just want something like this:
QueueBrowser queueBrowser = session.createBrowser(queue); queueBrowser.remove(JMSMessageID);
I know there is nothing like that. Is there anything similar I can do? How does a message actually leave the queue?
I am using Java 1.6.0_22 and JBoss AS 5.1.
Thanks in advance!
I figured it out. You have to receive it. This will remove it from the queue.
MessageConsumer msgConsumer = session.createConsumer(queue, "JMSMessageID='" + id + "'"); msgConsumer.receive(1000);