Multi-tenant Application with Axon Server Enterprise (AxonIQ Cloud)

Hello,

I recently came to the conclusion that our application could greatly benefit from using CQRS with Event Sourcing. We currently have multiple Spring Boot applications that work in a “traditional” manner. Our application must support multiple tenants. We chose to separate our data on a schema level. Hibernate currently takes care of selecting the data source. This makes it very convenient because we don’t need to worry about tenants when we implement new features.

I hoped that Axon would support multiple tenants but I cannot find a real guide for it. We want to use the Axon Enterprise Server because of its advertised multi-tenant support using contexts. How do we need to configure Axon to become tenant/multi-context aware?

I’ve found the REST API of the Axon Server which would allow the dynamic creation of new contexts specific to each tenant. However, Axon Framework seems to only support a single context in its configuration. I am also wondering how event handlers and so on subscribe to multiple contexts at the same time. It seems to be impossible to share computing resources for multiple tenants using Axon. The only solution I can come up with is to deploy separate applications for each tenant that are configured with the corresponding context. This, however, defeats the whole purpose of developing a multi-tenant application.

I hope I am missing some important piece.
Thank you in advance

Daniel

Hi Daniel, there are different levels of multi-tenancy, and Axon currently support some of them.

The first and third options from this picture are already supported, you can deploy the application per tenant per context already (multi-context - multi-tenant). But of course, this is not what you are looking for. The third option is to have a single context and to programmatically separate data from each tenant (logged-in user), based on your inquiry you don’t want either.

The second option is the one that you are looking for, context per tenant and application can be shared between tenants. This feature is not yet released, it’s currently in beta and will not be released before 4.6 Axon Framework and Axon Server. Although it possible to share with you an early release if you are curious to test it? The current state of this extension should cover all the cases that you are interested in. Also, we can schedule a meeting to present you new multi-tenant extension and to answer all of your questions. If you are interested please reach out to stefan.dragisic@axoniq.io

3 Likes