Given you have multiple systems, which are integrated by events, and all of them are using event sourcing. Where do you store the events?
In my case I have three systems:
- A website, which is a shop
- A backend for the Website to manage customers, products etc.
- An accounting system
Whenever a domain event happens in one of those systems the event is published and can be processed by the other systems. All systems are using event sourcing.
I am wondering where you would save the events. Of course each system has to store all events that it processed because it is using event sourcing and therefore depends on the events it once processed.
But what about the other events that where not needed and therefore the system did not subscribe to? I am struggling with the fact that requirements can change, such that a system would have to process events from the past that it did not persist. Where would you get these events from, if the system needed to process events that it did not subscribe when they occured?
I think there is a big difference to systems that do not use event sourcing at this point. If you have to implement a feature in a system A which depends on data, that is not available in A, but in another system B, and you persistent current state via a ORM tool like NHibernate you can simply import that data from A to B. Since a system, that uses event sourcing, depends on events to get to it's current state you have to import all the events that you missed in the past but are need now.
For me there are a few different approaches to this problem.
- Each system saves all events that is publishes. This gives you the ability to republish the events if needed or to import them into another system.
- Each system saves all events that happen, even those which do not need to be processed (yet).
- All events from all system are stored in central event log. If you need to proccess a event that happened in the past but you did not subscribe to you can import it from here.
How do you handle such a situation? Where do you save your events?
Edit
Thanks Roy Dictus for your answer. I'm still not sure how to handle the following situation:
The website publishes the events CustomerRegistered, CustomerPurchasedProduct and CustomerMarkedProductAsFavorite. In the current version of the backend customers haave to be displayed and their purchases have to be displayed. What a customer marked as a favorite is not of interest in that version of the system. Thus the backend only subscribed to CustomerRegistered and CustomerPurchasedProduct.
Now the marketing department also wants the information about the favorite products to be shown on the customer details page. Since the backend didn't subscribe to CustomerMarkedProductAsFavorite this information is not available in the backend. Where do I get that information from?