gautema/CQRSlite

Alternative function to use for obsolete function

daniel94104 opened this issue · 2 comments

[Obsolete("The eventstore should publish events after saving")]
public Repository(IEventStore eventStore, IEventPublisher publisher);

Above is the code snippet from CQRSLite domain file. I wonder if there is suggestion for alternative functions to use other than the above.

Thanks

Hi.

Take a look at the example code. The idea is that your code should first save to an event store, and then subscribe to changes from the database. The reasoning for this is that events should not be published before events are commited. Publishing from the repository encourages publishing in the same transaction which either requires two phase commits or might be a source of bugs if different storage or bus solutions are used.

If your database supports it you can subscribe to save events, or you can pull for new events at some interval. Or if you are sure there is only one transaction involved, publish the events from the event store your self.

Does this make any sense?

Hi

Thanks for the quick reply. I used this function in our test code. So, I think I am sure there is only transaction involved. So, I think I will suppress this warning then.

Thanks again for the helpful information.