If you want to remove messages from a queue via the management API there are a couple of methods you can use:
- removeMessage[1]: this method takes a messageID which allows you to remove a specific message (assuming you know its ID) - removeMessages[2]: this method takes a filter [3] which allows you to remove any message which matches the filter; if you pass an empty/null filter then *all* the messages will be removed The main thing to keep in mind with filters is that they operate on message headers and properties only. They don't operate on the *content* of the message. The only exception to this is if you're using an XPath filter [4], but that requires your message to be XML formatted text. Justin [1] https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/QueueControl.html#removeMessage(long) [2] https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/QueueControl.html#removeMessages(java.lang.String) [3] https://activemq.apache.org/components/artemis/documentation/latest/filter-expressions.html [4] https://activemq.apache.org/components/artemis/documentation/latest/filter-expressions.html#xpath On Thu, Apr 13, 2023 at 12:28 PM John Lilley <john.lil...@redpointglobal.com.invalid> wrote: > Greetings, > > > > I am using the queue-based ManagementHelper interface, which I use to > enumerate queues, browse messages, and purge queues. > > I would like to remove one or more matching messages from a queue. But I > can’t quite see how to do that. The “matching” requires deserialization of > the message to examine its contents. > > It doesn’t need to be fast. > > > > Thanks > > John > > > > > > [image: rg] <https://www.redpointglobal.com/> > > John Lilley > > Data Management Chief Architect, Redpoint Global Inc. > > 888 Worcester Street, Suite 200 Wellesley, MA 02482 > > *M: *+1 7209385761 <+1%207209385761> | john.lil...@redpointglobal.com > > PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is > confidential and is intended solely for the use of the individual(s) to > whom it is addressed. If you believe you received this e-mail in error, > please notify the sender immediately, delete the e-mail from your computer > and do not copy, print or disclose it to anyone else. If you properly > received this e-mail as a customer, partner or vendor of Redpoint, you > should maintain its contents in confidence subject to the terms and > conditions of your agreement(s) with Redpoint. >