Interface ISubscriptionExtension

All Superinterfaces:
ISubscriptionProcessor

public interface ISubscriptionExtension extends ISubscriptionProcessor
Interface to implement to define a subscription in SAGA. Each subscription will get its own asynchronous processing path, so an event can end up in multiple subscriptions. There is an async queue mechanism between accept(Event) and ISubscriptionProcessor.process(EventList)
  • Method Details

    • accept

      boolean accept(Event event)
      Here you decide if the subscription should process the event. You should not do any heavy work here, nor look into third party systems.

      This method should not invoke third party system, or other heavy processing but should rather inspect the event and make a quick decision whether it is relevant.

      Implementors are encouraged to handle exceptions thrown by this method locally and return false if unable to deal with them. Failure to do so will result in Saga raising an Issue and filtering out the events that caused the exception.

      If you need to do some heavy processing to find out if the event is relevant, then postpone that work to the ISubscriptionProcessor.process(EventList) step.

      Accepted events are placed on a queue for asynchronous processing - either in batches or individually depending on what you return in getProcessingOption().

      Parameters:
      event - for deciding on subscription processing
      Returns:
      true if the event should be processed
    • getProcessingOption

      ProcessingMode getProcessingOption()
      Here you define if you want to process events one-by-one (ProcessingMode.Individual) or in batches (ProcessingMode.Batch). Processing them individually has the benefit that if you throw a SubscriptionDelayException only one event will be pushed back. However, it may be more efficient to process events in batches.
      Returns:
      the processing mode that your subscription should use