Interface ISubscriptionExtension
- All Superinterfaces:
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 Summary
Modifier and TypeMethodDescriptionboolean
Here you decide if the subscription should process the event.Here you define if you want to process events one-by-one (ProcessingMode.Individual
) or in batches (ProcessingMode.Batch
).Methods inherited from interface com.persequor.extension.subscription.ISubscriptionProcessor
process
-
Method Details
-
accept
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 aSubscriptionDelayException
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
-