gautema / CQRSlite

A lightweight framework to help creating CQRS and Eventsourcing applications in C#
Other
1.1k stars 266 forks source link

Expected behavior of an IEventStore? #82

Closed aaronincincy closed 5 years ago

aaronincincy commented 5 years ago

Looking at the built in Repository it looks like after it saves the events to the event store it passes them on to the event publisher. Looking at the InMemoryEventStore in the sample, it looks like it saves the events to the in memory database, then calls the event publisher again. This seems like it would publish events twice unless I'm missing something. When implementing my own IEventStore should I reproduce the same behavior?

aaronincincy commented 5 years ago

Nevermind, I re-read the code when I wasn't so tired and I see that that is deprecated behavior now. For anyone reading this in the future, it was decided that the EventStore should publish events and the constructor for the Repository that accepted an event publisher was marked obsolete.

gautema commented 5 years ago

Great to hear that you found out about this one. The problem with using the repository to publish events is that transactions are required for it to work. This creates the need for two phase commits in many systems. To avoid this, it's better that the event store handles publishing.

aaronincincy commented 5 years ago

Yeah, I've since changed my approach again and I'm using an Azure Function with the CosmosDB trigger to publish events. I think this should solve the problem you mentioned with transactions. Thanks for following up, I'm really enjoying CqrsLite!

On Mon, Jan 21, 2019 at 7:12 AM Gaute Magnussen notifications@github.com wrote:

Great to hear that you found out about this one. The problem with using the repository to publish events is that transactions are required for it to work. This creates the need for two phase commits in many systems. To avoid this, it's better that the event store handles publishing.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/gautema/CQRSlite/issues/82#issuecomment-456053703, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsRQgeCozKAF7hvvX06so5ctetqeBpNks5vFa69gaJpZM4aI6yS .