T - event implementation storing the data for sharing during exchange or parallel coordination of an event.public final class BatchEventProcessor<T> extends java.lang.Object implements EventProcessor
RingBuffer
and delegating the available events to an EventHandler.
If the EventHandler also implements LifecycleAware it will be notified just after the thread
is started and just before the thread is shutdown.
| Constructor and Description |
|---|
BatchEventProcessor(DataProvider<T> dataProvider,
SequenceBarrier sequenceBarrier,
EventHandler<? super T> eventHandler)
Construct a
EventProcessor that will automatically track the progress by updating its sequence when
the EventHandler.onEvent(Object, long, boolean) method returns. |
| Modifier and Type | Method and Description |
|---|---|
Sequence |
getSequence()
Get a reference to the
Sequence being used by this EventProcessor. |
void |
halt()
Signal that this EventProcessor should stop when it has finished consuming at the next clean break.
|
boolean |
isRunning() |
void |
run()
It is ok to have another thread rerun this method after a halt().
|
void |
setExceptionHandler(ExceptionHandler<? super T> exceptionHandler)
Set a new
ExceptionHandler for handling exceptions propagated out of the BatchEventProcessor |
public BatchEventProcessor(DataProvider<T> dataProvider, SequenceBarrier sequenceBarrier, EventHandler<? super T> eventHandler)
EventProcessor that will automatically track the progress by updating its sequence when
the EventHandler.onEvent(Object, long, boolean) method returns.dataProvider - to which events are published.sequenceBarrier - on which it is waiting.eventHandler - is the delegate to which events are dispatched.public Sequence getSequence()
EventProcessorSequence being used by this EventProcessor.getSequence in interface EventProcessorSequence for this EventProcessorpublic void halt()
EventProcessorSequenceBarrier.alert() to notify the thread to check status.halt in interface EventProcessorpublic boolean isRunning()
isRunning in interface EventProcessorpublic void setExceptionHandler(ExceptionHandler<? super T> exceptionHandler)
ExceptionHandler for handling exceptions propagated out of the BatchEventProcessorexceptionHandler - to replace the existing exceptionHandler.public void run()
run in interface java.lang.Runnablejava.lang.IllegalStateException - if this object instance is already running in a threadCopyright © 2011 - 2018 LMAX Ltd. All Rights Reserved.