Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to artemis queue from command line?

Is there any way to purger artemis queues? I have already purged then by going cd data/paging. This is the location where I have installed my artemis broker.

There is a UI called haw.io of artemis , though I Have deleted all the files in the paging directory, it sill shows the message on the UI, which in the correct case should not be there.

Please suggest.

like image 609
addytheriot Avatar asked Jan 20 '26 17:01

addytheriot


2 Answers

From command line in your broker instance bin folder:

artemis queue delete --user user --password password --name queue-name
like image 193
Griso Avatar answered Jan 23 '26 20:01

Griso


Artemis Broker provides a REST management API that users can use to read and change many of the broker's parameters in run time. Therefore, it's possible to purge a queue from command line using a command line like this:

curl -X POST -H "Content-Type: application/json" -d  '{ "type": "EXEC", "mbean": "org.apache.activemq.artemis:address=\"test.performance.queue\",broker=\"0.0.0.0\",component=addresses,queue=\"test.performance.queue\",routing-type=\"anycast\",subcomponent=queues", "operation": "removeMessages(java.lang.String)", "arguments": [ "" ] }' http://localhost:8161/jolokia/exec | jq .

In this example above, I am purging the contents of a queue named test.performance.queue on a broker instance 0.0.0.0. These parameters need to be adjusted for the specific case.

Obs: note that I used jq . simply to make the response JSON prettier (you don't need to do that if you don't care about the response):

{
  "request": {
    "mbean": "org.apache.activemq.artemis:address=\"test.performance.queue\",broker=\"0.0.0.0\",component=addresses,queue=\"test.performance.queue\",routing-type=\"anycast\",subcomponent=queues",
    "arguments": [
      ""
    ],
    "type": "exec",
    "operation": "removeMessages(java.lang.String)"
  },
  "value": 13001,
  "timestamp": 1503740691,
  "status": 200
}

Another possibility, might be to use the BMIC tool, which provides access to several APIs used for managing ActiveMQ 6 and Artemis brokers (disclaimer: I am the maintainer of the tool). Using that, you can do the same thing using this command:

./bmic queue -u admin -p admin -s localhost --name test.performance.queue --purge

One benefit of the tool over the curl command is that you don't need to care about the broker parameters, as the tool will (try to) do the discovery for you.

like image 28
otavio021 Avatar answered Jan 23 '26 21:01

otavio021



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!