With NServiceBus you can subscribe by interface, eg:
public class MyEvent: ISomeInterface {}
public class Handler: IHandleMessages<ISomeInterface>{...}
This all seems to work happily, however when you have multiple interfaces eg:
public class MyEvent: ISomeInterface, ISomeOtherInterface {}
public class Handler: IHandleMessages<ISomeInterface>{/*Works fine*/}
public class Handler: IHandleMessages<ISomeOtherInterface>{/*Doesnt work*/}
When using pub/sub the message is correctly subscribed to in either case, but when the message is actually published the receiving service errors with:
No handlers could be found for message type: ISomeInterface
It appears to only work if the interface you are handling is the first on the sent message class. If I swap the order of interfaces on the actual event implementation around the second handler works fine but the first errors with a similar message (ie order of interfaces is whats causing the issue)
Is there some way to handle messages by interface no matter what order the interfaces were in when the message was constructed?
I've tried this with the handler using NSB 3 and NSB 4 both produce the same result.
EDIT:
As requested heres a more detailed snippet of the subscriber config I am using. I've also put together a minimal repro pub/sub app to demonstrate the issue I'm having (on github here).
Configure.Features.Disable<NServiceBus.Features.TimeoutManager>().Disable<NServiceBus.Features.SecondLevelRetries>();
Configure.With()
.DefineEndpointName("nsbinterfaces.subscriber")
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.Contains(".Events"))
//.NinjectBuilder(kernel)
.DefaultBuilder()
.UseTransport<Msmq>()
.PurgeOnStartup(false)
.MsmqSubscriptionStorage("nsbinterfaces.subscriber")
.UnicastBus()
.LoadMessageHandlers()
.ImpersonateSender(false)
.CreateBus()
.Start(
() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());