0

I'm using (the excellent) NEventStore to persist a stream of aggregate root events. In response to some state changes the aggregate dispatches commands to another endpoint. The aggregate root sends the command using a service that's passed in. This works fine whilst using msdtc but obviously at a cost.

Having witnessed the evil that is 2pc I'd now like to move to a architecture that has fault-tolerance built in. I understand that, during start up, NEventStore will automatically dispatch events that previously failed.

Does this suggest that all external state changing functionality should occur after the aggregate's events have been successfully dispatched, ie dispatch commands to the other endpoint in response to specific events from within the IDispatchCommits.Dispatch method?

Or, perhaps a unit-of-work would be better?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Joe
  • 333
  • 3
  • 10
  • Can you make one question out of this please. And read about sagas re 'state changing in response to events' of the kind you're angling towards . I think I answered a question re the commit id in one of these tags in the last few months. – Ruben Bartelink Jul 25 '13 at 20:38
  • I've reduced it one question as you requested. I'll search for your answer re commit id - thanks. Re sagas - I understand how they work. I'm more interested to know what patterns people use to overcome 2pc – Joe Jul 25 '13 at 21:42
  • Aggregates should not dispatch commands. Aggregates raise events. Handlers for events can dispatch commands (and those handlers should be idempotent to avoid a mess etc). Re-dispatch is not on startup btw - each time an event is written, all commits that have not been dispatched get passed to the dispatcher (which also means there's a race among each writing thread). Reading to the end... yes, all processing only happens in response to events that *have* happened (as opposed to command processing that one is attempting, which should be idempotent). i dont know what you mean by uow wrt es – Ruben Bartelink Jul 25 '13 at 21:49

0 Answers0