2014-12-03 134 views
5

有没有办法通过命令行(win/linux)删除/清除ActiveMQ中的所有队列? 我只能找到特定队列的命令。 或者也许有办法通过activeMQ管理员来做到这一点?再次,我只发现如何删除/清除队列中的一个接一个,这可能非常乏味。ActiveMQ - 通过命令行删除/清除所有队列

谢谢!

回答

10

你可以做调整你的activemq.xml一点:

<broker deleteAllMessagesOnStartup="true" ...> 

这适用于KahaDB邮件存储(它与JDBC消息存储问题),所有的邮件被删除,随后队列被清除。

由于您希望删除所有队列,因此重新启动代理并不是成本高昂的选项,无法清理所有内容。

+0

谢谢,它的工作原理! – Ayelet 2014-12-03 12:57:15

+0

它拯救了我的生命,谢谢! – walla 2016-05-01 17:15:06

+0

@瓦拉欢迎,很高兴帮助! – Vihar 2016-05-02 05:57:29

0

另一种可能性是在一个容器(例如Apache ServiceMix)中部署一个小型骆驼路由,或者只是通过执行一个包含该路由的java程序。

例如,下面是我目前我的开发计算机上使用的路线,我也已经安装了ServiceMix的:

<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>