MassTransit.MongoDb appears to ignore keyed IMongoClient factory when another unkeyed IMongoClient exists #6204
Unanswered
joaoantunesvisma
asked this question in
Q&A
Replies: 1 comment 2 replies
|
Well, I wouldn't say it's expected, but it's definitely an issue with the way the components are registered in the service collection. The types registered in the container are: Func<IServiceProvider, IMongoClient>? ProviderClientFactory;
Func<IServiceProvider, IMongoDatabase>? ProviderDatabaseFactory;You'd likely have to register your own versions of those that are move explicit, but I'm not sure it would be able to differentiate between them either way. Since the container treats these as magic factories, it's probably not the best way to do it going forward. I'll have to make a note to revisit the way it is configured. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi!
I am trying to support multiple MongoDB clients in the same container:
I expected this to work by configuring MongoDb outbox/saga repository with a keyed client factory.
What I want
Use MassTransit MongoDb outbox + saga repository with a specific keyed IMongoClient (replica set), even when another unkeyed IMongoClient is also registered in the container.
Observed behavior
Even though ClientFactory/DatabaseFactory resolve the keyed replica-set client, message processing fails with:
NotSupportedException: Standalone servers do not support transactions.
If I make the unkeyed IMongoClient also point to the replica-set client (alias), it succeeds.
My question
Is this expected behavior?
Does MassTransit.MongoDb internally resolve unkeyed IMongoClient / session paths that bypass the keyed factories?
If yes, what is the recommended way to support multiple Mongo clients with MongoDb outbox/saga repository?
Thanks for the help!
All reactions