rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.26k stars 355 forks source link

Handler called multiple times when using Lamar #871

Closed bosjaH closed 4 years ago

bosjaH commented 4 years ago

Hi,

A quick follow up to this comment.

This seems a consequence of the way Lamar resolves generics. With a message Message1 : IMessage1 and a handler Message1Handler : IHandleMessages<IMessage1>, the current GetMessageHandlersForMessage method will return 2 instances of Message1Handler if a message with type Message1 comes in.

Seems to me that an easy fix is selecting only the unique handler types. image

What do you think?

mookid8000 commented 4 years ago

Actually sounds like a pretty nice fix. 🙂

bosjaH commented 4 years ago

Created a PR with the change + unit test

mookid8000 commented 4 years ago

Closed by https://github.com/rebus-org/Rebus.ServiceProvider/pull/33

Thanks!