示例#1
0
 /**
  * Sets the throttling settings of the throttle manager.
  *
  * @param throttleSettings The throttling settings for the throttle manager.
  */
 public void setThrottleSettings(ThrottleSettings throttleSettings) {
   // Make sure that we have valid outbound policies.
   Policy outPolicy = throttleSettings.getOutboundPolicy();
   if (outPolicy != Policy.NONE && outPolicy != Policy.IGNORE) {
     ConfigurationException ex = new ConfigurationException();
     ex.setMessage(
         "Invalid outbound throttle policy '"
             + outPolicy
             + "' for destination '"
             + throttleSettings.getDestinationName()
             + "'. Valid values are 'NONE' and 'IGNORE'.");
     throw ex;
   }
   settings = throttleSettings;
 }
示例#2
0
 /**
  * Attempts to throttle destination-level incoming and outgoing messages.
  *
  * @param message Message to throttle.
  * @param incoming Whether the message is incoming or outgoing.
  * @return The result of the throttling attempt.
  */
 public ThrottleResult throttleDestinationLevel(Message message, boolean incoming) {
   if (incoming && settings.isInboundDestinationThrottleEnabled()) {
     ThrottleResult result =
         inboundDestinationMark.checkLimit(
             settings.getIncomingDestinationFrequency(), settings.getInboundPolicy());
     return result;
   } else if (!incoming && settings.isOutboundDestinationThrottleEnabled()) {
     ThrottleResult result =
         outboundDestinationMark.checkLimit(
             settings.getOutgoingDestinationFrequency(), settings.getOutboundPolicy());
     return result;
   }
   // Return the default OK result.
   return new ThrottleResult();
 }
示例#3
0
 /**
  * Returns the outbound policy being used by the throttle manager.
  *
  * @return The outbound policy for the throttle manager.
  */
 public Policy getOutboundPolicy() {
   return settings == null ? null : settings.getOutboundPolicy();
 }