【发布时间】: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