Description
Hello maintainers!
I am currently using Spring Data MongoDB in a multi-tenant environment. To give a little context, as a security requirement from our customers, we need to have a different credential set for every tenant, which forces us to have multiple instances of MongoClient
.
We managed to make this work by overriding the method doGetMongoDatabase
from SimpleMongoClientDatabaseFactory
, which I believe the way people usually do it. However, we're facing a really big issue with this way of doing thing: since we have multi instances of MongoClient
, using @Transactional
doesn't work properly. We end up with this error
java.lang.IllegalStateException: state should be: ClientSession from same MongoClient
Would you happen to have a fix for that? Or is it in your roadmap to offer an official support for multi-tenancy?
Thank you for your help!