Skip to content

Redundant handler and mapper registrations in consumer projects #2383

@nesbo

Description

@nesbo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions