示例#1
0
        private async Task ExecuteHandler(
            HandlerDescriptor handler,
            object message,
            VentureIncomingMessageHandlingContext context)
        {
            _logger.LogDebug(
                "Executing a message handler of type {HandlerType}.",
                handler.HandlerType.FullName);

            var stopwatch = Stopwatch.StartNew();

            try
            {
                await handler.OnHandle(message, context);
            }
            catch (Exception exception)
            {
                _logger.LogError(
                    exception,
                    "An error occurred during a message handler execution of type {HandlerType}.",
                    handler.HandlerType.FullName);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                _logger.LogDebug(
                    "Executed a message handler of type {HandlerType} in {Elapsed} milliseconds.",
                    handler.HandlerType.FullName,
                    stopwatch.ElapsedMilliseconds);
            }
        }