Interface EventHandlerBase<T>

All Superinterfaces:
EventHandlerIdentity
All Known Subinterfaces:
EventHandler<T>, RewindableEventHandler<T>, SequenceReportingEventHandler<T>
All Known Implementing Classes:
AggregateEventHandler

interface EventHandlerBase<T> extends EventHandlerIdentity
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    onBatchStart(long batchSize, long queueDepth)
    Invoked by BatchEventProcessor prior to processing a batch of events
    void
    onEvent(T event, long sequence, boolean endOfBatch)
    Called when a publisher has published an event to the RingBuffer.
    default void
    Called once just before the event processing thread is shutdown.
    default void
    Called once on thread start before first event is available.
    default void
    onTimeout(long sequence)
  • Method Details

    • onEvent

      void onEvent(T event, long sequence, boolean endOfBatch) throws Throwable
      Called when a publisher has published an event to the RingBuffer. The BatchEventProcessor will read messages from the RingBuffer in batches, where a batch is all of the events available to be processed without having to wait for any new event to arrive. This can be useful for event handlers that need to do slower operations like I/O as they can group together the data from multiple events into a single operation. Implementations should ensure that the operation is always performed when endOfBatch is true as the time between that message and the next one is indeterminate.
      Parameters:
      event - published to the RingBuffer
      sequence - of the event being processed
      endOfBatch - flag to indicate if this is the last event in a batch from the RingBuffer
      Throws:
      Throwable - if the EventHandler would like the exception handled further up the chain or possible rewind the batch if a RewindableException is thrown.
    • onBatchStart

      default void onBatchStart(long batchSize, long queueDepth)
      Invoked by BatchEventProcessor prior to processing a batch of events
      Parameters:
      batchSize - the size of the batch that is starting
      queueDepth - the total number of queued up events including the batch about to be processed
    • onStart

      default void onStart()
      Called once on thread start before first event is available.
    • onShutdown

      default void onShutdown()
      Called once just before the event processing thread is shutdown.

      Sequence event processing will already have stopped before this method is called. No events will be processed after this message.

    • onTimeout

      default void onTimeout(long sequence) throws Exception
      Parameters:
      sequence - - the last processed sequence.
      Throws:
      Exception - if the implementation is unable to handle this timeout.