Multi database or Multi collection with mongodb

Hi,

Is that possible to have multi database or multi collections in mongodb with Axon 3 when we do implement event store.

For example:
2 aggregates : BanckAccount and Transfer
How can I configure event store if I want to store these 2 type events separately in 2 databases or 2 collections ?

Best regards

Lei

Hi Lei,

it’s possible (and done before), but not always trivial. For storing the events, you can simply define 2 event stores (each with a different storage), and configure each repository to use a different one.
However, that would mean that on the event consuming side, you would have to read from 2 sources.

Alternatively, you could adapt (probably extend or wrap) the MongoEventStorageEngine to base the collection to store data in on the aggregate type, which is part of the event to Store. Overriding the MongoEventStorageEngine’s appendEvents method should get you a long way.
Still, there is a challenge on the read side, to make sure you read from the correct (or all) collections.

Hope this provides some pointers.
Cheers,

Allard