【问题标题】:ActiveMQ - delete/purge all queue via command lineActiveMQ - 通过命令行删除/清除所有队列
【发布时间】:2015-01-31 23:45:15
【问题描述】:

有没有办法通过命令行(win/linux)删除/清除 ActiveMQ 中的所有队列? 我只能找到特定队列的命令。 或者也许有办法通过activeMQ管理员做到这一点?同样,我只找到了如何一个一个地删除/清除队列,这可能非常繁琐。

谢谢!

【问题讨论】:

    标签: jms activemq message-queue


    【解决方案1】:

    你可以稍微调整一下你的activemq.xml

    <broker deleteAllMessagesOnStartup="true"  ...>
    

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

    由于您希望删除所有队列,因此重新启动代理不会是清理所有内容的代价高昂的选择。

    清除将在“每次”重启时发生

    【讨论】:

      【解决方案2】:

      我开发了自己的 ActiveMQ 命令行实用程序 (activemq-cli) 来执行此操作。你可以在这里找到它:https://github.com/antonwierenga/activemq-cli(命令 'purge-all-queues' 或 'remove-all-queues')。

      【讨论】:

        【解决方案3】:

        从 5.0 版开始,它看起来可以是 done using the CLI provided with ActiveMQ 本身:

        $ ActiveMQ/bin/activemq purge
        

        【讨论】:

        • dequeueCount 未更新为 0。清除工作后重新启动。
        【解决方案4】:

        另一种可能性是在容器中部署一个小的 Camel 路由(例如 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>
        

        【讨论】:

          【解决方案5】:

          1- 转到 amq bin 文件夹,在我的情况下:

          cd /opt/amq/bin
          

          2- 运行 amq 客户端:

          ./client
          

          3- 在所需队列上运行清除

          activemq:purge <QUEUE NAME HERE>
          

          【讨论】:

            猜你喜欢
            • 2021-03-08
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2016-08-28
            • 2012-08-17
            • 1970-01-01
            • 2013-10-24
            • 2018-09-10
            相关资源
            最近更新 更多