Using ReactiveGridFsTemplate I noticed that it is always user the main database, even if GridFsDatabase is specified. I've adopted the workaround of defining my Bean
@Bean
public ReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory(
MongoProperties properties, MongoClient mongo) {
String database = StringUtils.firstNonBlank(
properties.getGridFsDatabase(),
properties.getMongoClientDatabase());
return new SimpleReactiveMongoDatabaseFactory(mongo, database);
}
And I think this can be a useful solution for standard autoconfigure of ReactiveGridFsTemplate in org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration file
Comment From: wilkinsona
@mp911de @christophstrobl what would you recommend please?
Comment From: christophstrobl
Given MongoProperties.gridFsDatabase
exists, it's a bit odd that the imperative and reactive part behave in a different way selecting the database to use. Decorating the ReactiveMongoDatabaseFactory
the way it's done with GridFsMongoDbFactory
in MongoDbFactoryDependentConfiguration
seems to be a good approach.
Comment From: wilkinsona
Thanks very much, @christophstrobl.