Exemplo n.º 1
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();
 }
Exemplo n.º 2
0
  /**
   * Attempts to throttle client-level incoming messages only. Client-level outgoing messages are
   * throttled at the FlexClientOutboundQueueProcessor.
   *
   * @param message Message to throttle.
   * @return The result of the throttling attempt.
   */
  protected ThrottleResult throttleIncomingClientLevel(Message message) {
    String clientId = (String) message.getClientId();
    if (settings.isInboundClientThrottleEnabled()) {
      MessageFrequency clientLevelMark;
      clientLevelMark = inboundClientMarks.get(clientId);
      if (clientLevelMark == null)
        clientLevelMark = new MessageFrequency(settings.getIncomingClientFrequency());

      ThrottleResult result =
          clientLevelMark.checkLimit(
              settings.getIncomingClientFrequency(), settings.getInboundPolicy());
      inboundClientMarks.put(clientId, clientLevelMark);
      return result;
    }
    // Return the default OK result.
    return new ThrottleResult();
  }