Persist Domain Events in MSSQL database in spring boot 2

Hi,

As I am new to the Axon Framework, how can I persist the domain events in an MSSQL database instead of storing them in the Axon server flat file “./data/default/000000000000000000.events”?. I am using spring boot 2.

1 Like

Hi,

you cannot change the way Axon Server stores its events. These “flat files” are Axon Server’s internal data storage, which are optimized for efficient event storage and retrieval.

If you want to use MSSQL to store your events, you should configure your application to use an EmbeddedEventStore with a JPA or JDBC Storage engine. You can find more information here: Event Bus & Event Store - Axon Reference Guide

Note that relational databases are reasonable at storing events, especially when they’re empty. When data volumes grow, they generally suffer from severe performance degradation. Also, they will generally use much more storage to store the same amount of data as Axon Server would.

Hi Allard,

Thank you for your reply.

My ultimate goal is to use a database with built-in failover capabilities to handle event store availability issues and ensure continuity in case of failures.

Implementing failover capabilities is not feasible when storing events in a flat file. To tackle the growing data concern, we can employ snapshots as a solution. Snapshots capture the current state of an aggregate at a specific point in time, providing an optimization for event replay and reducing the volume of data needed to reconstruct an aggregate’s state.

Hi Mohamad,

AxonServer, just like MSSQL, is a database, except that it is designed to efficiently and at constant performance store streams of events. It stores its current state on disk for durability reasons. For failover, you would create a cluster of AxonServer nodes, just like you would create a cluster of MSSQL nodes. To ensure the highest possible level of consistency, AxonServer uses the Raft protocol.

The clustering capability is included in AxonServer Enterprise edition only. The standard edition will offer a standalone version, which doesn’t cover the HA case you’re referring to.
You can get a free 3-day trial license for AxonServer Enterprise here.

Unfortunately, experience has shown this is not enough. While this will reduce the amount of events you would need to read from the database, we have seen that databases severely suffer from performance degragation simply because of the amount of events stored. Even appending events will become slower over time.

There is an interesting benchmark by Digital Frontiers from Germany where Marco Amman (now a colleague at AxonIQ) compared AxonServer to Postgres and MongoDB.

Thank you so much for providing such valuable information! Your insights have been incredibly helpful, and I truly appreciate your assistance.