public abstract class

AggregatorDispatcher

extends Object
implements IEventListener
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.events.AggregatorDispatcher

Class Overview

An event aggregator-dispatcher. This object is useful when the frequency of events reception is getting high - and as a consequence, event processing time getting larger (relatively) than events incoming period. Events are aggregated and dispatched only after either many events have been received or a timeout has elapsed.

Summary

Public Constructors
AggregatorDispatcher()
Create a new aggregator-dispatcher with a capacity of 100, and a resolution of 250 ms.
AggregatorDispatcher(int capacity, long triggerResolution)
Create a new aggregator-dispatcher.
Public Methods
int capacity()
void onEvent(IEvent e)
abstract void onMultipleEvents(List<IEvent> events)
This method is called by the aggregator-dispatcher whenever any of the following condition occurs: enough events were collected; or enough time has elapsed.
long resolution()
int unattended()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.util.events.IEventListener

Public Constructors

public AggregatorDispatcher ()

Create a new aggregator-dispatcher with a capacity of 100, and a resolution of 250 ms.

public AggregatorDispatcher (int capacity, long triggerResolution)

Create a new aggregator-dispatcher.

Parameters
capacity event capacity, at least 1: after that many events are received, onMultipleEvents(List) routine is called
triggerResolution a resolution in milliseconds: the period at which the event queue is automatically dispatched and cleaned, regardless of whether the capacity was reached. Careful: 0 is a valid resolution at which the auto-dispatcher is disabled, ie, events are dispatched ONLY when the aggregator is at full capacity

Public Methods

public int capacity ()

public void onEvent (IEvent e)

public abstract void onMultipleEvents (List<IEvent> events)

This method is called by the aggregator-dispatcher whenever any of the following condition occurs: enough events were collected; or enough time has elapsed.

Thread notes: This method may be called by the thread that generated the event, or any other worker thread used by the aggregator-dispatcher. Execution of this method is serialized: the next execution of onMultipleEvents(List) will not start until the previous execution has terminated.

Parameters
events the list of collected events

public long resolution ()

public int unattended ()