fmtn / a

ActiveMQ CLI testing and message management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filter consumed messages (-g) with the selector (-s) ?

frabar opened this issue · comments

To cleanup a messy queue, I would like to consume (-g) all messages based on a specific selector.

Here is what I tried:

# Content of my queue:
########################

$ ./a  --broker tcp://test-broker-1:61616  test
-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"ActiveMQTest@lan.local",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

-----------------
Message Properties
  event_category: can
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"ActiveMQTest@lan.local",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"ActiveMQTest@lan.local",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

Operation completed in 30067ms (excluding connect)

# Browse messages with selector
########################

$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'"  test
-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"ActiveMQTest@lan.local",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"ActiveMQTest@lan.local",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

Operation completed in 30081ms (excluding connect)

# Trying to get messages with selector
########################

$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'" -g  test
No message received
Operation completed in 125ms (excluding connect)
$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'" -c 5 -g  test
No message received
Operation completed in 114ms (excluding connect)
$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'" -c 0 -g  test
No message received
Operation completed in 96ms (excluding connect)

Since the documentation says:

-s,--selector Browse or get with selector

So now it could be a bug 🐛 or PEBKAC 😊 . In any case, I hope you can help me out here.

Thanks in advance!

Some times with remote brokers you need to provide some wait time. Default is 50ms, but with selectors over network it might not be enough. Try providing -w 1000. I tried to reproduce it, but it works as expected with a localhost broker. Maybe the 50ms default value should be longer.

Thanks for your suggestion. Unfortunately it doesn't work.
I tried -w 1000 with the same commands as above.

The used ActiveMQ Version is 5.14.1

Not able to reproduce