Unfortunately, as you have discovered, Rebus does not expect handlers (including sagas) to be wrapped in decorators.
It uses decorators a lot for various things internally, and it encourages the use of decorators as an extension point for developers, but that only goes for all of Rebus' services like IPipeline
, ISubscriptionStorage
, etc.
If you want to log stuff in relation to message handling, a better extension point would be to either
a) use Rebus.Events
and simply install an event handler like this:
Configure.With(...)
.(...)
.Events(e => {
e.AfterMessageHandled += (bus, headers, message, context, args) => {
// log stuff in here :)
};
})
.Start();
or
b) create an incoming pipeline step that logs what you want to log like this:
Configure.With(...)
.(...)
.Options(o => {
o.Decorate<IPipeline>(c => {
var step = new YourLoggingStep();
var pipeline = c.Get<IPipeline>();
return new PipelineStepInjector(pipeline)
.OnReceive(step, PipelineRelativePosition.After, typeof(DeserializeIncomingMessageStep));
});
})
.Start();
probably wrapping all of the ugly stuff in an extension method that makes usage look more like this:
Configure.With(...)
.(...)
.Options(o => {
o.LogHandledMessages();
})
.Start();