Some confusion on using IHandleMessages
I have a subscriber that subscribes to multiple different publishers. All of these publishers post a message whose interface derives from a base interfaces. This base message contains some common attributes that all the messages require and is a marker.
public interface IBaseMessage : IMessage
{}
public inteface IPublisher1Message : IBaseMessage
{}
public inteface IPublisher2Message : IBaseMessage
{}
In the subscriber I have created a class that subscribes to all publishers in the system.
public BaseMessageHandler : IHandleMessages<IBaseMessage>
{
public void Handle(IBaseMessage message) {}
}
I would like this to Handle the message from all publishers, but I have seen it fire for a开发者_如何转开发t most one publisher depending on how I do my message endpoint mappings.
<MessageEndpointMappings>
<add Messages="Messages.IPublisher1Messages,Messages" Endpoint="Publisher1" />
<add Messages="Messages.IPublisher2Messages,Messages" Endpoint="Publisher2" />
</MessageEndpointMappings>
Is there a way to handle messages from different publishers in one Handler?
Are you relying on auto-subscribe for this one?
Because I think I can recall having had some kind of trouble similar to yours - as I remember it, the solution was to manually subscribe to each message.
You can still rely on polymorphic message dispatch, it's just polymorphic auto-subscription that seems not to work.
精彩评论