Class IdentityAggregationPolicy<T extends Message>

  • All Implemented Interfaces:
    AggregationPolicy<T,​T,​T>

    public class IdentityAggregationPolicy<T extends Message>
    extends Object
    implements AggregationPolicy<T,​T,​T>
    An aggregation policy that returns the original unmodified message as the aggregate.
    Author:
    jwhite
    • Constructor Detail

      • IdentityAggregationPolicy

        public IdentityAggregationPolicy()
    • Method Detail

      • key

        public Object key​(T message)
        Description copied from interface: AggregationPolicy
        Calculate a key for the given message. Objects with the same key will be aggregated together. Returned values should non-null.
        Specified by:
        key in interface AggregationPolicy<T extends Message,​T extends Message,​T extends Message>
        Parameters:
        message - the message
        Returns:
        the message's key
      • aggregate

        public T aggregate​(T accumulator,
                           T newMessage)
        Description copied from interface: AggregationPolicy
        Aggregate the given message into an existing accumulator, or create a new accumulator if no accumulator exists.
        Specified by:
        aggregate in interface AggregationPolicy<T extends Message,​T extends Message,​T extends Message>
        Parameters:
        accumulator - the existing accumulator, or null if a new accumulator should be created
        newMessage - the message to aggregate
        Returns:
        the new or updated accumulator
      • build

        public T build​(T accumulator)
        Description copied from interface: AggregationPolicy
        Build the resulting message from the accumulator.
        Specified by:
        build in interface AggregationPolicy<T extends Message,​T extends Message,​T extends Message>
        Parameters:
        accumulator - an existing accumulator
        Returns:
        the aggregated message to dispatch
      • getCompletionSize

        public int getCompletionSize()
        Description copied from interface: AggregationPolicy
        Maximum number of messages to be added to a bucket before dispatching. If this value is <= 1, the buckets should be dispatched immediately after adding a single element.
        Specified by:
        getCompletionSize in interface AggregationPolicy<T extends Message,​T extends Message,​T extends Message>
        Returns:
        maximum number of messages per bucket
      • getCompletionIntervalMs

        public int getCompletionIntervalMs()
        Description copied from interface: AggregationPolicy
        Maximum number of milliseconds for which buckets should continue accumulating messages after creation. If a bucket has been created for longer than this interval, it will be dispatched regardless of it's current size. Values <= 0 will disable periodic flushing and buckets will only be dispatched once they have reached the maximum size.
        Specified by:
        getCompletionIntervalMs in interface AggregationPolicy<T extends Message,​T extends Message,​T extends Message>
        Returns:
        number of milliseconds to keep a bucket before dispatching