Class ThrottlingAggregator<T>


  • public class ThrottlingAggregator<T>
    extends java.lang.Object
    Aggregates items, grouping them if they are submitted consecutively within a specified delay or if a specified maximum delivery frequency dictates that no more deliveries can be made at the time.

    Delivery happens when either of the following occur:

    • The time since the last item submitted is longer than the specified delay and a delivery wasn't sent out too recently.
    • There are items waiting to be delivered and a period of time longer than the specified frequency elapses.
    • Constructor Detail

      • ThrottlingAggregator

        public ThrottlingAggregator​(long delay,
                                    long maxFrequency,
                                    ThrottlingAggregator.Callback<T> callback)
        Create a ThrottlingAggregator with the given parameters.
        Parameters:
        delay - How long to wait for another call to processItem before attempting delivery. During this delay is where aggregation happens.
        maxFrequency - The maximum frequency at which aggregated items should be delivered.
        callback - A callback that aggregated items will be delivered to.
    • Method Detail

      • processItem

        public void processItem​(T item)