> I’ve been looking for examples on how to use that “options” string in the
ManagementHelper API for listing queues, but I’m coming up empty… can you
point me to a link?

I forgot to address this point...

The "listQueues" method is what the web console uses and what the "artemis
queue stat" CLI command uses. You can get insight into the "field",
"value", and "operation" inputs from "artemis help queue stat" which lists
(in part):

        --field <fieldName>
            field to use in filter. Possible values NAME, ADDRESS,
            MESSAGE_COUNT, MESSAGES_ADDED, DELIVERING_COUNT, MESSAGES_ACKED,
            SCHEDULED_COUNT, ROUTING_TYPE.

        --operation <operationName>
            operation to use in filter. Possible values CONTAINS,
NOT_CONTAINS,
            EQUALS, GREATER_THAN, LESS_THAN.

        --value <value>
            value to use in the filter.

Hope that helps.


Justin

On Thu, Jan 5, 2023 at 10:05 AM Justin Bertram <jbert...@apache.org> wrote:

> The ManagementHelper API is there to help you create & structure
> management messages which the broker receives and parses in order to invoke
> methods on the corresponding JMX MBeans [1]. So in your current code you're
> effectively using something like this:
>
>   ManagementHelper.putAttribute(request, "queue.myQueue", "messageCount");
>
> There are JMX MBeans for every acceptor, address, queue, divert, bridge,
> etc. as well as one for the broker itself. This particular management
> message will get the "messageCount" attribute from the QueueControl [2] for
> the queue named "myQueue".
>
> In my previous email I recommended you use the "listQueues" [3] method of
> the ActiveMQServerControl with an options string like
> `{"field":"MESSAGE_COUNT","value":"0","operation":"GREATER_THAN"}`. To do
> this with the ManagementHelper API you'd do something like this:
>
>   ManagementHelper.putOperationInvocation(message, "broker", "listQueues",
> "{\"field\":\"MESSAGE_COUNT\",\"value\":\"0\",\"operation\":\"GREATER_THAN\"}",
> 1, 999);
>
>
> Justin
>
> [1]
> https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/package-summary.html
> [2]
> https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/QueueControl.html
> [3]
> https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.html#listQueues(java.lang.String,int,int)
>
>
>
> On Wed, Jan 4, 2023 at 8:52 AM John Lilley
> <john.lil...@redpointglobal.com.invalid> wrote:
>
>> Justin,
>>
>>
>>
>> I note that you talk about the ActiveMQServerControl API instead of the
>> ManagementHelper queue-based API.  We aren’t using that, IIRC, because the
>> embedded broker we use for testing doesn’t stand up the web service
>> component.  But if that is mistaken I can try it again.
>>
>>
>>
>> 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
>>
>> *From:* John Lilley <john.lil...@redpointglobal.com.INVALID>
>> *Sent:* Wednesday, January 4, 2023 7:45 AM
>> *To:* users@activemq.apache.org
>> *Subject:* RE: Can I use management API without blocking queue
>> auto-deletion?
>>
>>
>>
>> **** [Caution] This email is from an external source. Please use caution
>> responding, opening attachments or clicking embedded links. ****
>>
>>
>>
>> Justin,
>>
>>
>>
>> I’ve been looking for examples on how to use that “options” string in the
>> ManagementHelper API for listing queues, but I’m coming up empty… can you
>> point me to a link?
>>
>>
>>
>> Thanks
>>
>> John
>>
>>
>>
>>
>>
>>
>>
>> [image: rg]
>> <https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,KoMzBWmq6iQxtewdkBTqcodMnGzWhdI1LCr1Ia9LEh4ism0tlMZwkopTPTY0jX6ymN9QRsIdvEodFINlW6Z8NFK60sQt8gWC48y-oSsIunY1ye9AjCfBuw,,&typo=1>
>>
>> *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
>>
>> *From:* Justin Bertram <jbert...@apache.org>
>> *Sent:* Tuesday, January 3, 2023 6:29 PM
>> *To:* users@activemq.apache.org
>> *Subject:* Re: Can I use management API without blocking queue
>> auto-deletion?
>>
>>
>>
>> **** [Caution] This email is from an external source. Please use caution
>> responding, opening attachments or clicking embedded links. ****
>>
>>
>>
>> As far as I can tell this is the same message you sent a few days ago.
>> You can find my response to that message here [1].
>>
>>
>>
>>
>>
>> Justin
>>
>>
>>
>> [1] https://lists.apache.org/thread/p2lxw22nhwhq015lvjn0kqtxdsdj3vx4
>>
>>
>>
>> On Tue, Jan 3, 2023 at 7:13 PM John Lilley <
>> john.lil...@redpointglobal.com.invalid> wrote:
>>
>> Greetings!
>>
>>
>>
>> In our app, we have a lot of batch “jobs”, each of which stands up an RPC
>> service on a unique queue.  However, when jobs quit, clients may still try
>> to communicate and I don’t want this to hang, I want clients to see an
>> error reply.  To this end, I am implementing a “fallback” service for
>> ended-job RPC queues, of which there can be 100s,  that returns errors.
>> This is expected to be very low traffic and the polling can be done
>> infrequently (like every few seconds), so performance doesn’t matter.
>>
>>
>>
>> The queues are set to auto-delete, and in order to keep broker memory
>> down, I don’t want to do anything to prevent auto-deletion.  Because in
>> most cases, nothing will be posted to these queues.  I want to use a
>> strategy like this:
>>
>> •             Enumerate queues first, to see which ones exist.
>>
>> •             Of the queues that exist, use the queue-based management
>> API to get a message count (see method below).
>>
>> •             Only for queues that have a non-zero message count, create
>> a consumer and call receive() to poll for messages.
>>
>>
>>
>> Will this strategy avoid interfering with the broker’s auto-delete?
>>
>> Is queue enumeration low-impact enough to call it every few seconds?
>>
>>
>>
>> Method used for getting queue count (this is all using the
>> artemis-jms-client-all JMS client):
>>
>>
>>
>> public int getQueueEntryCount(String queueName) {
>>
>>   return getIntAttribute(queueName, "MessageCount");
>>
>> }
>>
>>
>>
>> private int getIntAttribute(final String queueName, final String
>> attributeName) {
>>
>>   String resourceName = ResourceNames.QUEUE + queueName;
>>
>>   synchronized (lock) {
>>
>>     ClientRequestor client = getClient();
>>
>>     try {
>>
>>       ClientMessage request = clientSession.createMessage(false);
>>
>>       ManagementHelper.putAttribute(request, resourceName, attributeName);
>>
>>       ClientMessage reply = client.request(request);
>>
>>       if (ManagementHelper.hasOperationSucceeded(reply)) {
>>
>>         return (int)(long)ManagementHelper.getResult(reply, Long.class);
>>
>>       } else {
>>
>>         // Because we cannot tell the difference between
>> queue-does-not-exist and a real error
>>
>>         return 0;
>>
>>       }
>>
>>     }
>>
>>     catch (Exception e) {
>>
>>       throw new RuntimeException("Error fetching " + attributeName + "
>> for queue " + queueName, e);
>>
>>     }
>>
>>   }
>>
>> }
>>
>>
>>
>> Thanks
>>
>> John
>>
>>
>>
>>
>>
>> [image: rg]
>> <https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,YqbMUNoeamPC97jmQb4P1scjW-m5h_6VLnZe3RY_dAwyd2emuHr9JkPxjitr-9AACE5Dqotd3di0Llbr-jzgCJQ9YlqIUvqoriHIvYiabZdUNGJN&typo=1>
>>
>> *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.
>>
>>
>> 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.
>>
>

Reply via email to