/** Updates the incoming client level message frequency. */ public void updateMessageFrequencyIncomingClientLevel(Message message) { String clientId = (String) message.getClientId(); if (settings.isInboundClientThrottleEnabled()) { MessageFrequency clientLevelMark = inboundClientMarks.get(clientId); if (clientLevelMark != null) clientLevelMark.updateMessageFrequency(); } }
/** Starts the throttle manager. */ @Override public void start() { // Use the default ThrottleSettings if one is not set already. if (settings == null) settings = new ThrottleSettings(); if (settings.isDestinationThrottleEnabled()) { inboundDestinationMark = new MessageFrequency(settings.getIncomingDestinationFrequency()); outboundDestinationMark = new MessageFrequency(settings.getOutgoingDestinationFrequency()); } if (settings.isInboundClientThrottleEnabled()) inboundClientMarks = new HashMap<String, MessageFrequency>(); }
/** * 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(); }