[英]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.