Closed jens-jonsson closed 4 years ago
I'm not sure if that will work 😁
First thing to look for would be what your IoC container returns when resolving a list of IHandleMessages<IFailed<object>>
Sorry should have been more clear on that.
Calling IServiceProvider.GetServices<IHandleMessages<IFailed<object>>>()
returns a list containing an instance of my registered handler.
Calling
IServiceProvider.GetServices<IHandleMessages<IFailed<object>>>()
returns a list containing an instance of my registered handler.
oh sorry, what I meant was this: Try and see what the container returns when resolving a list of IHandleMessages<IFailed<YourMessageType>>
IServiceProvicer.GetServices<IHandleMessages<IFailed<PublishEntityCommand>>>
works fine too, returning a list with my handler in it.
Base problem seems to be that stacking generics like IMessageHandler<T>
where T is IFailed<U>
does not work as I thought.
I guess if IFailed<>
implemented e.g. a new marker interface IFailed
I could use IHandleMessages<IFailed>
and then work my way to what type the wrapped message is and what exception lies behind the failure.
Basically I am looking for a way to intercept all failed messages (after all retries have failed) regardless of type to be able to send it to telemetry for tracking. Much just like the example of using IFailFastChecker
enables you to hook into the retry mechanism before the message fails permanently.
Decorating IErrorHandler works but context is lost and by that also our original correlationId.
Made a pull request with a proposed solution
Fixed in Rebus.ServiceProvider 5.0.2 🙂 Thanks @Tsjunne for your contribution! 👍
Trying to create a handler to handle all failed messages by implementing
IHandleMessages<IFailed<object>>
.Documentation suggests that implementing
IHandleMessages<object>
will call the handler for all messages but my constraint of IFailedI am on .net core using default IServiceProvider. Checking assembly scanning shows that my handler gets registered but not called for failed messages.