[英]How to set ActiveMQ to stop accepting messages?
我想知道,在ActiveMQ中是否存在任何属性,用户可以使用这些属性来限制ActiveMQ在达到特定阈值后不接受输入队列中的消息? 到目前为止,我已经能够使用内存约束找到其流控制。 我想在输入队列达到其特定阈值时动态地阻塞我的输入队列 。 是否有其他软件可以帮助我实现目标?
可能的方法是将自定义代理拦截器插入ActiveMQ。
为您的Spring Broker配置提供以下功能:
<plugins>
<bean id="myPlugin" class="org.foo.CheckThresholdPlugin"/>
</plugins>
然后扩展BrokerPlugin以覆盖send方法。
package org.foo;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerPlugin;
public class CheckThresholdPlugin extends BrokerFilter {
public void send(ProducerBrokerExchange producer, Message message) throws Exception {
boolean isOverThreshold = /* figure it out by getting Destination from Message */
if (isOverThreshold) {
throw new Exception("The threshold is exceeded.");
} else {
super.send(producer, message);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.