我想知道在 ActiveMQ 中是否有任何属性可以限制 ActiveMQ 在达到某个阈值后不接受输入队列中的消息?到目前为止,我能够使用内存约束找出它的流量控制。当输入队列达到其特定阈值时,我想动态阻止我的输入队列。有没有其他软件可以帮助我实现我的目标?
问问题
518 次
1 回答
0
可能的方法是将自定义代理拦截器插入 ActiveMQ。
使用以下内容补充您的 Spring 代理配置:
<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);
}
}
}
于 2013-05-16T07:12:51.217 回答