You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by John Lilley <jo...@redpointglobal.com.INVALID> on 2023/04/13 17:28:13 UTC

deleting matching message from queue

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




[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<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@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.

RE: deleting matching message from queue

Posted by John Lilley <jo...@redpointglobal.com.INVALID>.
Thanks!

So it sounds like I can browse the queue, find matching messages, and then use the delete-by-ID call?  Can I get the ID from a JMS message, or do I need to be at the AMQ API level for that?

john




[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<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>
From: Justin Bertram <jb...@apache.org>
Sent: Thursday, April 13, 2023 2:59 PM
To: users@activemq.apache.org
Subject: Re: deleting matching message from queue

*** [Caution] This email is from an external source. Please use caution responding, opening attachments or clicking embedded links. ***

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 <jo...@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




[rg]<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,YazC3O6Rk_C3QclXNw83NFNRnnQ9YPi0hEes8vPJqHzXJUsoaXe01R6hy40uunsYvfKvZYEeJjCwKApTcsjUtkGbAz21xJ6lAdMifPxvtqd5foYFyZZbbmcx&typo=1>

John Lilley

Data Management Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@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.

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.

Re: deleting matching message from queue

Posted by Justin Bertram <jb...@apache.org>.
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
<jo...@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.lilley@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.
>