From 1bc1595a97a782742807a9d1bf82634d56771a61 Mon Sep 17 00:00:00 2001 From: luox78 <1023354041@qq.com> Date: Wed, 2 Jun 2021 09:22:28 +0800 Subject: [PATCH] Add try catch on Dispatcher.Processing when invoke subscriber (#900) * Fix Dashboard metric not update #811 * Add try catch on Dispatcher.Processing when invoke subscriber --- src/DotNetCore.CAP/Processor/IDispatcher.Default.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs b/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs index d2f21cc..3195169 100644 --- a/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs +++ b/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs @@ -98,7 +98,15 @@ namespace DotNetCore.CAP.Processor { while (_receivedChannel.Reader.TryRead(out var message)) { - await _executor.DispatchAsync(message.Item1, message.Item2, _cts.Token); + try + { + await _executor.DispatchAsync(message.Item1, message.Item2, _cts.Token); + } + catch (Exception e) + { + _logger.LogError(e, + $"An exception occurred when invoke subscriber. MessageId:{message.Item1.DbId}"); + } } } }