Multiple event stores in modular monolith? #1490
-
I am creating a quite complex system in a modular monolith setup. All modules are decoupled as far as practical, and they interact through messaging and events on a bus. Internally I want to use event sourcing for at least a few of these modules, but since they are all running in the same host, I am not sure how to initialize Cratis Chronicle. The default Asp.Net config extension only allows for one EventStore. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Sorry for very late reply on this, it completely flew under the radar. The default configuration of Chronicle is as you say to hook up the IoC for As a general rule of thumb, I would say that separating out per module is a good idea as it then enables you to in practice also in the future to run them as separate processes / containers if one wants. What we tend to think is a good idea is to start by identifying the boundaries and DDDs bounded context is what we lean towards to guide us. That being said, decoupling at a module level introduces new complexities in terms of communication between different modules. This is where we tend to talk about the inbox <-> outbox pattern where one module would be producing "public" events that are not the same events as your "private" events and put these in an outbox. Any other module could then be subscribing to this outbox and get a copy of them in an inbox specific to the source. We don't have this formalized in Chronicle just yet, but the design and issue is ready and something we will have in the near future (#1473). Going back to the original question of then having multiple event stores in one process. The ASP.NET setup we have today doesn't have anything for it. But I can absolutely see the use case for it. If you want an automated hook up, it would need to be able to understand context. One way could be to introduce a required HTTP header (e.g. x-module) that would then be used to resolve which event store to use. For Chronicle, we could have a way to configure this by adding a "discriminator" strategy to the setup where you could chose the strategy and for HTTP header, chose the name of the header. Let us know what you think. |
Beta Was this translation helpful? Give feedback.
Sorry for very late reply on this, it completely flew under the radar.
The default configuration of Chronicle is as you say to hook up the IoC for
IEventStore
and such for one EventStore type of scenario. In a way assuming you will divide your modules into separate processes.As a general rule of thumb, I would say that separating out per module is a good idea as it then enables you to in practice also in the future to run them as separate processes / containers if one wants. What we tend to think is a good idea is to start by identifying the boundaries and DDDs bounded context is what we lean towards to guide us.
That being said, decoupling at a module level introduces new complexities i…