You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This double registration is a problem and we should change the way our startup code works to fix it. It might be as simple as a flag noting that registration has already been done.
Originally posted by nesbo November 25, 2022
Hi guys!
I obviously have problem understanding the registrations of async handlers and mappers when I have IHostedService that has to build and run the Dispatcher.
So, I have regular service registration in my Worker console project, building IServiceCollection. Here I must .AddBrighter() and register async handlers and mappers explicitly (or use AutoFromAssemblies - which I'd like to avoid btw).
Then, in my IHostedService I'm building up the Dispatcher with CommandProcessorFactory, passing the SubscriberRegistry where I had to register my handlers again, and to the DispatcherBuilder passing another MessageMapper with same map like I had in the service registration in the beginning.
Only if I do the registrations in both places (or use AutoFromAssemblies), the worker starts consuming messages from the bus and instantiating handlers.
I'd really like to avoid redundant registrations if possible.
Please let me know what I'm doing wrong here.
Thanks!
Aleks
The text was updated successfully, but these errors were encountered:
iancooper
changed the title
Redundant handler and mapper registrations in consumer projects
[Bug] Redundant handler and mapper registrations in consumer projects
Jan 5, 2023
This double registration is a problem and we should change the way our startup code works to fix it. It might be as simple as a flag noting that registration has already been done.
Discussed in #2395
Originally posted by nesbo November 25, 2022
Hi guys!
I obviously have problem understanding the registrations of async handlers and mappers when I have IHostedService that has to build and run the Dispatcher.
So, I have regular service registration in my Worker console project, building IServiceCollection. Here I must .AddBrighter() and register async handlers and mappers explicitly (or use AutoFromAssemblies - which I'd like to avoid btw).
Then, in my IHostedService I'm building up the Dispatcher with CommandProcessorFactory, passing the SubscriberRegistry where I had to register my handlers again, and to the DispatcherBuilder passing another MessageMapper with same map like I had in the service registration in the beginning.
Only if I do the registrations in both places (or use AutoFromAssemblies), the worker starts consuming messages from the bus and instantiating handlers.
I'd really like to avoid redundant registrations if possible.
Please let me know what I'm doing wrong here.
Thanks!
Aleks
The text was updated successfully, but these errors were encountered: