So this warning will show up whenever there are more events in event store but the Saga is still processing the previous event? Is there a tolerance or just lagging one event behind will cause consumer to switch to a local event stream
Another related question: My Saga has two event handlers. Is each handler a EventConsumer or just one EventConsumer for the one Saga? I think the second one is the correct answer?
Hi Chun Fu (I hope I am spelling that correctly?),
This message you’re seeing is not necessarily tied to a Saga.
The message comes up if one of the threads for a TrackingEventProcessor is falling behind in regards to event handling compared to the rest.
So, yes, this might be for a Saga, as a Saga might be backed by a TrackingEventProcessor; but really, it can be any type of Event Handling Component which receives its events from a Tracking Event Processor.
The decision when to move over from tailing the global event consumption towards a private stream, is based on whether a consumer has fallen behind the global consumer’s cache.
This ‘cachedEvents’ field can be configured for your EmbeddedEventStore.
For that, please take a look at the javadoc of the EmbeddedEventStore.Builder, as can be found here.
For your second question:
An Event Consumer typically services several Saga instances entirely.
So yes, you will not have an Event Consumer per Event Handler contained in a Saga, or any Event Handling Component to be exact.