Skip to content

Introduce AbstractRoutingMongoDatabaseFactory #3636

Open
@pelletier197

Description

@pelletier197

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: team-attentionAn issue we need to discuss as a team to make progresstype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions