Using MassTransit 3.5 with RabbitMQ as the transport.
We have no need for the _error queues created when a message consumer throws an exception. We try to make sure our consumers don't throw, but if something slips through in production we prefer to log and throw away the message without the error queue filling up.
I have tried:
1. Custom middleware, much like the one from the example page here, to catch and log the exception and then not rethrow. The problem with that is that the message doesn't get marked as "consumed", which leads to it being placed in the _skipped queue instead.
2. Created a custom filter much like ConsumerMessageFilter, which would similarly catch and log the exception and then call "context.NotifyConsumed" in the exception handler. I realize NotifyConsumed is meant for internal use. The problem there is that I can't find a way to easily hook up a filter taking a ConsumeContext with the generic type parameter from client code.
Additional ideas:
- Configure a retry policy to retry once, but call a special handler on the retry. Don't think this is possible.
- The mysterious (to me) configuration method "UseRescue" pipe configurator that says to "rescue exception via the alternate pipe". I'm not sure if this could achieve what I'm looking for.
Any guidance on how this may be possible?
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/085ffe41-cfd2-47fb-a1ae-f37b02833e9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class CustomExceptionRescuePipe :
IFilter<ExceptionConsumeContext>
{
public Task Send(ExceptionConsumeContext context, IPipe<ExceptionConsumeContext> next)
{
// Log here…
Console.WriteLine("Error occured");
context.NotifyConsumed(context, // Context needs to be of type CosumeContext<T>
TimeSpan.Zero,
TypeMetadataCache<TConsumer>.ShortName); // Type is also needed here
return Task.CompletedTask;
}
}
Writing your own rescue pipe would be ideal, since that is how the message is moved to _error internally. Adding your own would give you the exception, and let you log it. And feel free to call NotifyConsumed() at that point - it just signals the infrastructure so that the message isn't written to _skipped.This shows how it's done for the receive endpoint:
On Thu, Feb 23, 2017 at 8:37 AM, BDyke wrote:
Using MassTransit 3.5 with RabbitMQ as the transport.
We have no need for the _error queues created when a message consumer throws an exception. We try to make sure our consumers don't throw, but if something slips through in production we prefer to log and throw away the message without the error queue filling up.
I have tried:
1. Custom middleware, much like the one from the example page here, to catch and log the exception and then not rethrow. The problem with that is that the message doesn't get marked as "consumed", which leads to it being placed in the _skipped queue instead.
2. Created a custom filter much like ConsumerMessageFilter, which would similarly catch and log the exception and then call "context.NotifyConsumed" in the exception handler. I realize NotifyConsumed is meant for internal use. The problem there is that I can't find a way to easily hook up a filter taking a ConsumeContext with the generic type parameter from client code.
Additional ideas:
- Configure a retry policy to retry once, but call a special handler on the retry. Don't think this is possible.
- The mysterious (to me) configuration method "UseRescue" pipe configurator that says to "rescue exception via the alternate pipe". I'm not sure if this could achieve what I'm looking for.
Any guidance on how this may be possible?
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
Hi
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/085ffe41-cfd2-47fb-a1ae-f37b02833e9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/7d55e354-d80b-4abd-a69e-46f99d1cf1a3%40googlegroups.com.To post to this group, send email to masstransit-discuss@googlegroups.com.
Hi
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/085ffe41-cfd2-47fb-a1ae-f37b02833e9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.