Replaying events from multiple event stores

Hi Allard,

I was reading through the docs and came across that part for Replaying events from the event store. I’m kind of new to Event Sourcing, so I have several questions.

In a eCommerce application we have 3 write models to handle an Order processing and a query model model that serves as a reporting database.

Each of the write models is a stand alone service that run on a different machine with its own database. Necessary data is duplicated across all models to insure services are autonomous.

The 1st write model handles Order placement. The 2nd handles Order procurement. The 3rd handles Order shipment.

Questions:

  1. Should I have a single Event store for all 3 services? or should each service have its standalone Event Store?

  2. In case of multiple Event stores, how do I replay events from all 3 services to handle a new query requirement? Does Axon support replaying for multiple Event Stores or must I replay them in series?!

  3. Do I still need a database for the write model if an Event Store is used?

Hi,

you’re most likely best off using a single Event Store for all write models. That means each application will have an Event Store instance with the same backing database. That will allow each instance to do a full replay.

You can even use the same identifiers in each of the applications, as long as the aggregates have different names. The type (defaults to Aggregate’s name) and identifier, together, make up the unique identifier for an event stream.

When you use an event store, the event stream becomes your write model storage. Your write model is reconstructed using the events it previously generated. Other storage for your write model has become obsolete.

Hope this helps.
Cheers,

Allard

Sorry for the late reply. Won’t using a single backing database defeat the purpose of having several autonomous services?

My initial goal was to have a database for each service(i.e. Bounded Context), so that decoupling between the bounded context is reduced to a minimum.

Is that a wrong approach?

Hi,

it’s not a wrong approach. It might be a bit more cumbersome to replay events from different sources, but independence is also worth a lot.

Personally, I always use a single instance for all components. The components are still independent (of each other) and can be scaled up and down at will.

Cheers,

Allard

Hi,

can you give some helping hints how you would design a replay service that needs to return all events of multiple event stores with pagination?How to ensure the chronological order?

Hi Adriano,

just wondering, why pagination? The replay of the events is done using streaming, so pagination shouldn’t be necessary. Just read from the stream.

The issue with the current design is that the replay only supports the push method. You’d have to build two visitors that maintain a backlog of a number of events. A third component could feed itself off the visitors and read the events from the backlog of both visitors, each time processing the one with the lowest timestamp.

Hope this helps.

Cheers,

Allard