CQRS/EventStore : How to dispatch undispatched events?

587 views Asked by At

With the amazing library EventStore 3.0 there is a

store.Advanced.GetUnDispatchedCommits();

What is the best way/pattern to dispatch these?

Do I simply loop and call my dispatcher and then update the commit to indicate it has been dispatched (if so how would I do this)?

Also, during the wiring up of the EventStore, a dispatch is attempted on undispatched commits at start up. How can I avoid this from being done?

These questions are more to do with learning how EventStore works rather than a problem with a project.

1

There are 1 answers

0
Jonathan Oliver On BEST ANSWER

The "dispatch scheduler" is the thing that attempts to load up all undispatched commits during startup. You could create your own and override the method that is called at startup. At the same time, I wouldn't recommend it. The model behind the EventStore is all about fault tolerance and failure recovery. Specifically, if the machine dies just after a commit has been persisted and the dispatcher hasn't yet finished pushing the message onto the wire, you want the EventStore to pickup where it left off at startup by dispatching any undispatched commits.