We are utilizing the MongoDB Persistence module with NServiceBus, and our company has utility library for MongoDB that creates and configures MongoClient instances that are configured in a common way and address some cross-cutting concerns.
We would like to have the MongoDB Persistence module utilize a MongoClient that is created by our utility library. The utility library is managing the MongoClient objects within ASP.NET Core dependency-injection container. At the point that we can configure the MongoDB Persistence module (IHostBuilder.UseNServiceBus
) there is not an IServiceCollection or IServiceProvider that we can hook into to resolve a MongoClient from the dependency-injection container.
I’m looking for ideas of how we could accomplish this, or perhaps the persistence module could be enhanced to rely on the dependency-injection container to resolve dependencies such as the MongoClient instance?
Thanks!