简体   繁体   中英

How to set ActiveMQ to stop accepting messages?

I want to know that in ActiveMQ is there any property with which user can restrict ActiveMQ to not accept the messages in an Input Queue after a certain threshold is reached ? So far i am able to find out its flow control using memory constraint . I want to dynamically block my input queue when input queue reaches its certain threshold. Is there any other software which can help me to achieve my goal ?

Possible way is to plug custom broker interceptor into ActiveMQ.

Supple your Spring broker configuration with:

<plugins>
  <bean id="myPlugin" class="org.foo.CheckThresholdPlugin"/>    
</plugins>

Then extend BrokerPlugin to override send method.

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);
        }
    }

} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM