Replay events with sagas

Hello, thank you for your time.

Question about replaying events with Tracking Event Processor.

I have a Saga where I have an Event which produces another event. And all of them are stored in the Event Store.

But when I replay events from the Saga, events which have been produced inside Saga by other events - stores at event store for one more time. It this’s a bug ? or normal behavior ?

Hi @VladimirTitov4,

What do you mean by replay events from the Saga?
Saga is a Component which does not support Replays in general as, most of the time, the @EventHandlers from a Saga have side effects.

If you can expand a bit on what you are doing, that would be nice!

KR,

Hello, Lucas! Thank you for your reply!

Actually I’m replaying all events from my event store and some of the Events come to a Saga, where some transactional code needs to be done.
And inside that Saga original Event produces other Events, as it is usually done in saga. And those events which have been produced by original event store at event store once more time.

I thought that it works like that. I have some Events in Event store. I’m replaying them and that events just execute in replay and do not store at event store again ? But events which have been produced inside Saga - stores once more time

Hi @VladimirTitov4,

So, my question is: how are you replaying events?
How are you triggering this replay? I believe the answer for your question will be somewhere here.

But, to add to your statement:

And inside that Saga original Event produces other Events, as it is usually done in saga.

This is not usual and not recommended!
The usual is to fire a Command which will go towards an Aggregate, which will have validations in place to check if that given Command should or shouldn’t apply an Event!

KR,

I configure token store and manually clear that token store and when token store has been cleared - event replaying starts.
As I understand the case I explained above is an automatic event replaying?

I have read somewhere that there could be manual event replaying by configuring EventProcessingConfiguration?

Is there any difference in Event Replaying with automatic & manual launch ?

Blockquote
This is not usual and not recommended!
The usual is to fire a Command which will go towards an Aggregate, which will have validations in place to check if that given Command should or shouldn’t apply an Event!

Yes, sorry I didn’t explained myself correctly, inside Saga I fire commands and then handle an Event produced by this command.

Hi @VladimirTitov4,

That helps a lot and follows my suspection.

In short, no, this is not a replay. By “cleaning the token store”, this is not a replay but a regular event handling - it would be impossible for the framework to know if it’s a replay or not if you do not have a token! And since this is a regular event handling, all your @Sagas Event Handler will be (correctly) called.

For proper replaying, I can point you to our docs or to our code-samples where you can find the recommended way of doing that.

KR,