Lets say I have two bounded contexts Project and Budgets. When project adds new member it is publishing MemberAdded event. Budgets listen to this events and it creates local version of Member entity - it just holds what it needs. This will work fine if both services are deployed at the same time. Lets say I use kafka. These MemberAdded events will be stored for example for next 7 days and then kafka deletes them. What if later I need to add new service for example Orders that also need replicated version of Member entity - Customer. I would need to start listening for MemberAdded events but I would still not have old data. How you can handle this case? The only solution I can think of is to use persistent event store that I can query for all events and from this I could restore all data required for new service.
Asked
Active
Viewed 58 times
1 Answers
1
You have two options:
- Use a persistent event store and store all events ever generated. This can be thought of a pull system, where new services (or even old services) can fetch data as and when they need it.
- Regenerate events from the source system on the fly (Project) and target them to specific services (using a particular pub-sub or message channel, for example). This can be considered a push system, where you must trigger republishing of old events whenever another part of the system needs to access data from another service.
Needless to say, the former is much more efficient and is a one-time effort to gather all events at a central location than the latter, which needs you to do some work whenever a new service (or old service) needs to access/process data from another service.
Extending the thought process, the central event store can also double up as a source of truth and help in audits, reporting, and debugging if made immutable (like in the event sourcing pattern).

Subhash
- 3,121
- 1
- 19
- 25
-
1Thank you for answer. I was thinking to go persistent event store way because if I need to manage event bus system I can manage event store instead with pub sub and it would give me also a future possibility to go with event sourcing for some new service if I really need it. – Arczewski Dec 03 '22 at 19:38
-
That's correct. Please bear in mind that the decision to go with event sourcing is more involved and nuanced and often has to be decided early in development. – Subhash Dec 04 '22 at 01:20