Separate database for event store and state store

Hello,

I am trying to use 2 different databases for event-store ( command side) and state-store (query side). I also want to setup custom EventSourcingRepository to setup cache.

Can you help me find a way in which I can connect event-sourcing repository to spring.datasource-a.url and state-store repository to spring.datasource-b.url.

Thank you,
Sumanth Kumar Mora

Hi Sumanth,

Are you using Spring? I’m going to assume you do, but let me know if that was not the case.

An EventSourcingRepository doesn’t use a datasource directly. It just uses an Event Store. If you use the EmbeddedEventStore, then the actual database connection is used by the [Jpa/Jdbc]EventStorageEngine.
You would need to configure your 2 datasources in Spring, and then configure a JdbcEventStorageEngine to use one, and you query repository to use the other.

Besides configuring the JdbcEventStorageEngine, which you can simply define as a Bean in your application context, and Spring Boot will auto-configure the rest for you. The remaining configuration is more specific to Spring than Axon.

Hope this helps.
Cheers,