Support for multi-tenancy #128
Replies: 3 comments 8 replies
-
I currently have the same issue. I use schema-based multi-tenancy. For that to work, the table event_publication must have a column tenant that is then used to set the TenantContext (ThreadLocal in my case). Do you have any plans to support multi-tenancy? |
Beta Was this translation helpful? Give feedback.
-
Multi-tenancy in Spring applications is usually implemented in a |
Beta Was this translation helpful? Give feedback.
-
Really? I almost always did schema per tenant as very often the schemas are created on the fly when a new tenant registers. Whatever the implementation is, how do you solve the problem that the thread that is consuming the events is not tenant-aware? |
Beta Was this translation helpful? Give feedback.
-
We are developing a service that supports multi-tenancy. One schema per tenant is created using the available JPA features for multi-tenancy.
Issues arise with the current implementation of the EventPublicationRegistry. For this feature to work, all registry entries must be in the same schema and cannot be spread across different tenant schemas. We worked around this by configuring custom entity and transaction managers. The default entity and transaction managers are picked up by Modulith. These are not configured with any multi-tenancy features which works just fine. The second set of entity and transaction managers are configured with multi-tenancy features and are used by our application.
This setup works just fine for the happy path. However, if a transactional event handler fails and the event is retried on restart, it is published with the wrong transaction manager. Thus, the wrong schema is selected by our code and the required tables are not found.
Is there any way that configuring multi-tenancy with Modulith can be simplified? We would greatly appreciate any information on how to support multi-tenancy with Modulith.
I am not very experienced with entity and transaction managers. I feel like a simple configuration for the used transaction managers that are used by Modulith could go a long way. So one transaction manager for the event publication registry and another one for publishing retried events.
Beta Was this translation helpful? Give feedback.
All reactions