Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Redundant handler and mapper registrations in consumer projects #2401

Open
iancooper opened this issue Dec 5, 2022 Discussed in #2395 · 1 comment
Open

[Bug] Redundant handler and mapper registrations in consumer projects #2401

iancooper opened this issue Dec 5, 2022 Discussed in #2395 · 1 comment
Assignees
Labels
feature request v10 Allocal to a v10 release

Comments

@iancooper
Copy link
Member

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

@iancooper iancooper added the Bug label Dec 5, 2022
@iancooper iancooper added this to Needs triage in Death to Bugs via automation Dec 5, 2022
@iancooper iancooper moved this from Needs triage to Low priority in Death to Bugs Dec 5, 2022
@iancooper iancooper changed the title Redundant handler and mapper registrations in consumer projects [Bug] Redundant handler and mapper registrations in consumer projects Jan 5, 2023
@iancooper iancooper added v10 Allocal to a v10 release feature request and removed Bug labels Feb 8, 2024
@holytshirt
Copy link
Member

Posted to thread and duplicating it here
I think @nesbo just needs use the dispatcher from the servicecollection in his Ihostedservice, like how we do in our extension
https://github.com/BrighterCommand/Brighter/blob/master/src/Paramore.Brighter.ServiceActivator.Extensions.Hosting/ServiceActivatorHostedService.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request v10 Allocal to a v10 release
Projects
Death to Bugs
  
Low priority
Development

No branches or pull requests

2 participants