【问题标题】:How to set ActiveMQ to stop accepting messages?如何设置 ActiveMQ 停止接受消息?
【发布时间】:2013-05-09 13:58:12
【问题描述】:

我想知道在 ActiveMQ 中是否有任何属性可以限制 ActiveMQ 在达到某个阈值后不接受输入队列中的消息? 到目前为止,我能够使用 内存约束 找出它的流量控制。 我想在输入队列达到其特定阈值时动态阻止我的输入队列。 有没有其他软件可以帮助我实现目标?

【问题讨论】:

    标签: java rabbitmq activemq qpid


    【解决方案1】:

    可能的方法是将自定义 broker interceptor 插入 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);
            }
        }
    
    } 
    

    【讨论】:

      猜你喜欢
      • 2014-05-25
      • 1970-01-01
      • 1970-01-01
      • 2012-09-10
      • 2011-02-23
      • 1970-01-01
      • 2014-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多