【问题标题】:How to destroy thousand of ActiveMQ queues on demand in short period of time?如何在短时间内按需销毁数千个 ActiveMQ 队列?
【发布时间】:2015-07-01 11:11:51
【问题描述】:

我们正在使用数千个队列在系统内部传递数据。出现的问题是销毁它总是需要很多时间,而且我们必须等到队列确定不再使用。

为此,我们目前使用以下方法

try {
  _consumer.getEndpoint().stop();
  _consumer.stop();
}
catch (Exception ex) {
  System.out.println("Error: " + ex.getMessage());
}

// Wait a little, so that ActiveMQ has time to realize that the endpoint is destroyed,
// which is necessary to be done before the queue is destroyed,
// otherwise we get an "Error: Destination still has an active subscription: queue://receive:XXX":

try {
  Thread.sleep(1);
}
catch (InterruptedException ex) {
  System.out.println("Error: " + ex.getMessage());
}

// Destroy queue:
String shortRxQueueName = _rxQueueName.replace("activemq:queue:", "");
try {
  activeMQConnection.destroyDestination(new ActiveMQQueue(shortRxQueueName));
}
catch (JMSException ex) {
  System.out.println("Error: " + ex.getMessage());
}

即使我们试图省略与代理的连接并使用当前可用的activeMQConnection,停止 300 个队列也需要大约 50 秒。

3402: Stopping clients...
53500: Stopping camel context...

因此,对于每个销毁队列,我们​​消耗 0.16 秒。

如何让它更快?骆驼是否包含诸如池或缓存队列之类的东西来执行操作?

【问题讨论】:

  • 你有权限启动/停止服务器吗?
  • 是的。但在目标系统中,服务器应该连续工作。 W 想限制为新连接做好准备的队列数量并释放资源。

标签: java multithreading apache-camel activemq


【解决方案1】:

我不知道这是否适合你的要求,但你可以看看这个

ActiveMQ - delete/purge all queue via command line

它的作用是,当activemq启动时,它会删除所有队列和消息。

希望这会有所帮助! 祝你好运!

【讨论】:

    猜你喜欢
    • 2013-08-31
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    • 2016-10-25
    • 1970-01-01
    • 1970-01-01
    • 2019-05-26
    • 2019-12-06
    相关资源
    最近更新 更多