Is there any way to intercept messages in NServiceBus?
From now i can do it manually via introducing base message handler like this:
public abstract class MessageHandler<T> : IHandleMessages<T>
where T : IMessage
{
public IBus Bus { get; set; }
protected abstract void HandleCommand(T command);
public void Handle(T command)
{
// perform some logic on *command* before
HandleCommand(command);
// perform some logic on *command* after
}
}
And the usage:
public class ConcreteMessageHandler : MessageHandler<ConcreteMessage>
{
protected override void HandleCommand(ConcreteMessage message)
{
//handle command
}
}
But doing this way i'm loosing an ability to subscribe to multiple messages (because i cannot inherit from multiple MessageHandler<>
classes).