Unhandled Exception in RabbitMQ Message Consumer Thread, was not caught by AppDomain.CurrentDomain.UnhandledException #1650
-
Hi, We have an application which throws an unhandled exception in the message consumer thread, but AppDomain.CurrentDomain.UnhandledException event didn't get triggered. I have attached the some example code below. Please help us. We would be appreciate if you can schedule a meeting to review this case. Thanks, Pramod Code Example: AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException;
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
var props = ea.BasicProperties;
throw new Exception("consumer errror 2");
}; |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@Pramod34 we will not schedule any meetings with users who are neither paying customers nor contributors. We do not have any relevant information to work with:
In general, RabbitMQ clients expect applications to handle consumer exceptions because libraries It may be reasonable to expect un unhandled exception to be propagated as a |
Beta Was this translation helpful? Give feedback.
-
I created some example code to show how to deal with exceptions in event handlers, like for the https://github.com/lukebakken/rabbitmq-dotnet-client-1650/blob/main/Program.cs When you run that console application, and publish a message to the queue, you can see that the We do not support version 5 of this library, however, this is the code in version 6 that calls callback exception handlers: You can see that the exception is swallowed. In your case, you should use the |
Beta Was this translation helpful? Give feedback.
@Pramod34 -
I created some example code to show how to deal with exceptions in event handlers, like for the
Received
event:https://github.com/lukebakken/rabbitmq-dotnet-client-1650/blob/main/Program.cs
When you run that console application, and publish a message to the queue, you can see that the
CallbackException
handler is called.We do not support version 5 of this library, however, this is the code in version 6 that calls callback exception handlers:
https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/6.x/projects/RabbitMQ.Client/client/impl/ModelBase.cs#L400-L416
You can see that the exception is swallowed.
In your case, you should use the
OnConnectionCallbackException
handlers to