When processing events why create an async scope? #200
Unanswered
iem365-michael
asked this question in
Q&A
Replies: 0 comments
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 all,
Just looking to expand my understanding; appreciate any support.
In RabbitMQEventBus.cs when processing an event within ProcessEvent there is a new async scope created.
await using var scope = serviceProvider.CreateAsyncScope();This is then used to resolve the keyed IIntegrationEventHandlers.
foreach (var handler in scope.ServiceProvider.GetKeyedServices<IIntegrationEventHandler>(eventType))As the handlers are injected as transient:
eventBusBuilder.Services.AddKeyedTransient<IIntegrationEventHandler, TH>(typeof(T));This scope appears redundant to me, and I would look to resolve the services directly from the service provider?
Beta Was this translation helpful? Give feedback.
All reactions