コード例 #1
0
        private async Task HandleMessageWithContent(IMessage <T> message)
        {
            try
            {
                Log.Debug($"Processing message of type {typeof(T).FullName}", message.Content.ToDictionary());
                try
                {
                    _messageContextProvider.StoreMessageContext(message);
                    await ProcessMessage(message.Content);
                }
                finally
                {
                    _messageContextProvider.ReleaseMessageContext(message);
                }

                await message.CompleteAsync();

                Log.Info($"Completed message {typeof(T).FullName}");
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Failed to process message {typeof(T).FullName}");

                if (message?.Content != null)
                {
                    await message.AbortAsync();
                }

                await OnErrorAsync(message, ex);
            }
        }