spring-projects / spring-session-data-mongodb

Spring Session for MongoDB
https://spring.io/projects/spring-session-data-mongodb
Apache License 2.0
50 stars 35 forks source link

Spring session in a multidatasource environment #170

Open visweshwar opened 4 years ago

visweshwar commented 4 years ago

How to configure additional Datasource for Spring Session #96

96

By default spring-session-data-mongodb assumes that the datasource in the project is exclusively used by spring session. If you have more than 1 dataSource, the very first bean gets elected to the primary Datasource for session. This is less than ideal. To account for this I've added an annotation to optionally elect the datasource of choice.

Expected behavior The MongoTemplate annotated with SpringSessionMongoOperations will be chosen as the Session Datasource

Actual behavior Currently the first Bean gets resolved as the MongoOperations of choice.

Steps to reproduce https://github.com/visweshwar/spring-session-multiple-mongo can reproduce the issue.