Multi-tenancy with multiple bounded contexts per tenant

Hi,

the new multi-tenancy extension looks very promising. I am currently in the process of integrating it into our existing services. The extension uses Axon contexts to separate the tenant events. I am wondering how the extension deals with multiple bounded contexts per tenant. Especially, if we send commands between different contexts or react to domain events from another bounded context.

As far as I understand I would need to adjust the TenantConnectPredicate so the application connects to all contexts that it wants to interact with which seems very extraneous. We recently had a large Axon bill because we used too many processing groups without realizing it. We are now changing our code to use very few processing groups to save costs.

With this in mind, how would we go about configuring the extension to be able to have multiple contexts per tenant, send commands between contexts, and receive events from different contexts?

I’m not sure if you are on the right track if you want to save costs, let me elaborate:

If you have 4 bounded contexts and you decide to go multitenant, then you will need a context per tenant, so that’s already 4 contexts per tenant and in the case of 10 tenants that would be 40 contexts.

It is possible to use bounded contexts as before, by defining targetContextResolver bean, which has higher priority over tenantTargetResolver. You will also be able to set multiStremableMessageSource to consume messages from different tenants (contexts), but as you may notice you will now have (in the case of 10 tenants only) 40 contexts communicating between each other and the number of messages might be really high which has implied higher cost on Axon Cloud. This is as Enterprise setup as it gets, although it’s possible to achieve, its a not good road to go if you want to be cost-efficient, and not the best case to deploy on the Cloud, as for such a complex system you might want to control every single aspect of it on your local Axon Server Enterprise cluster.

1 Like