ActiveMQ - delete / clear the entire queue through the command line

Is there a way to remove / clear all queues in ActiveMQ via the command line (win / linux)? I could only find teams for a specific queue. Or maybe there is a way to do this using the activeMQ administrator? Again, I just found how to remove / clean the queues one by one, which can be very tedious.

Thanks!

+10
source share
5 answers

You can customize your activemq.xml :

 <broker deleteAllMessagesOnStartup="true" ...> 

This works with KahaDB message stores (there are problems with JDBC message stores), all your messages are deleted, and then the queues are cleared.

Since you want to delete all queues, restarting the broker will not be an expensive option to clear everything.

Cleaning will occur every time you restart

+17
source

I developed my own ActiveMQ command-line utility (activemq-cli) to do this. You can find it here: https://github.com/antonwierenga/activemq-cli (command 'purge-all-queues' or 'remove-all-queues').

+4
source

As in version 5.0, it looks like this could be done using the CLI provided by ActiveMQ itself :

 $ ActiveMQ/bin/activemq purge 
+3
source

Another possibility is to deploy a small Camel route in a container (for example, Apache ServiceMix) or simply run a java program that contains the route.

For example, here is the route I am currently using on my development computer, where I also have ServiceMix installed:

 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd"> <cm:property-placeholder persistent-id="amq.cleanup" update-strategy="reload"> <cm:default-properties> <cm:property name="amq.local.url" value="tcp://localhost:61616" /> </cm:default-properties> </cm:property-placeholder> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <onException useOriginalMessage="true"> <exception>java.lang.Exception</exception> <handled> <constant>true</constant> </handled> <to uri="activemq:queue:CLEANUP_DLQ" /> </onException> <route id="drop-all-queues" autoStartup="true"> <from uri="activemq:queue:*.>" /> <stop/> </route> </camelContext> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="brokerURL" value="${amq.local.url}" /> </bean> </blueprint> 
0
source

1- go to the amq bin folder, in my case:

 cd /opt/amq/bin 

2- run amq client:

 ./client 

3- start cleaning the desired queue

 activemq:purge <QUEUE NAME HERE> 
0
source

Source: https://habr.com/ru/post/1208230/


All Articles