diff --git a/src/JustSaying/Fluent/ISubscriptionBuilder`1.cs b/src/JustSaying/Fluent/ISubscriptionBuilder`1.cs index 30f55d387..cde88488c 100644 --- a/src/JustSaying/Fluent/ISubscriptionBuilder`1.cs +++ b/src/JustSaying/Fluent/ISubscriptionBuilder`1.cs @@ -37,16 +37,16 @@ public interface ISubscriptionBuilder ///
  • Before_SomeCustomMiddleware
  • ///
  • Before_SomeOtherCustomMiddleware
  • ///
  • Before_MessageContextAccessorMiddleware
  • - ///
  • Before_ErrorHandlerMiddleware
  • ///
  • Before_LoggingMiddleware
  • ///
  • Before_StopwatchMiddleware
  • ///
  • Before_SqsPostProcessorMiddleware
  • + ///
  • Before_ErrorHandlerMiddleware
  • ///
  • Before_HandlerInvocationMiddleware
  • ///
  • After_HandlerInvocationMiddleware
  • + ///
  • After_ErrorHandlerMiddleware
  • ///
  • After_SqsPostProcessorMiddleware
  • ///
  • After_StopwatchMiddleware
  • ///
  • After_LoggingMiddleware
  • - ///
  • After_ErrorHandlerMiddleware
  • ///
  • After_MessageContextAccessorMiddleware
  • ///
  • After_SomeOtherCustomMiddleware
  • ///
  • After_SomeCustomMiddleware
  • @@ -72,4 +72,4 @@ public interface ISubscriptionBuilder IVerifyAmazonQueues creator, IAwsClientFactoryProxy awsClientFactoryProxy, ILoggerFactory loggerFactory); -} \ No newline at end of file +} diff --git a/src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs b/src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs index 0248abcd9..0b633ff3b 100644 --- a/src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs +++ b/src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs @@ -36,7 +36,7 @@ public static class HandlerMiddlewareBuilderExtensions /// /// /// Applies a set of default middlewares in order. Adding other middlewares before this will add them - /// to the top of the stack, and are run first and last. + /// to the top of the stack, and are run first to last. /// Adding other middleware after this will add them to the bottom of the stack, just before the /// handler itself is invoked. /// @@ -44,10 +44,10 @@ public static class HandlerMiddlewareBuilderExtensions /// /// MessageContextAccessorMiddleware /// BackoffMiddleware (only if an is available) - /// ErrorHandlerMiddleware /// LoggingMiddleware /// StopwatchMiddleware /// SqsPostProcessorMiddleware + /// ErrorHandlerMiddleware /// HandlerInvocationMiddleware`1 /// /// @@ -65,12 +65,12 @@ public static class HandlerMiddlewareBuilderExtensions if (handlerType == null) throw new ArgumentNullException(nameof(handlerType), "HandlerType is used here to"); builder.UseMessageContextAccessor(); - builder.UseErrorHandler(); builder.Use(); builder.UseStopwatch(handlerType); builder.Use(); + builder.UseErrorHandler(); builder.UseHandler(); return builder; } -} \ No newline at end of file +} diff --git a/src/JustSaying/Messaging/Middleware/Logging/LoggingMiddleware.cs b/src/JustSaying/Messaging/Middleware/Logging/LoggingMiddleware.cs index bd222b980..b6d37311e 100644 --- a/src/JustSaying/Messaging/Middleware/Logging/LoggingMiddleware.cs +++ b/src/JustSaying/Messaging/Middleware/Logging/LoggingMiddleware.cs @@ -44,7 +44,7 @@ protected override async Task RunInnerAsync(HandleMessageContext context, { if (dispatchSuccessful) { - _logger.LogInformation(MessageTemplate, + _logger.LogInformation(context.HandledException, MessageTemplate, Succeeded, context.Message.Id, context.MessageType.FullName, @@ -52,7 +52,7 @@ protected override async Task RunInnerAsync(HandleMessageContext context, } else { - _logger.LogWarning(MessageTemplate, + _logger.LogWarning(context.HandledException, MessageTemplate, Failed, context.Message.Id, context.MessageType.FullName, @@ -60,4 +60,4 @@ protected override async Task RunInnerAsync(HandleMessageContext context, } } } -} \ No newline at end of file +} diff --git a/tests/JustSaying.IntegrationTests/Fluent/Configuration/Approvals/WhenUsingNamingConventions.ThenTheNamingConventionIsApplied.approved.txt b/tests/JustSaying.IntegrationTests/Fluent/Configuration/Approvals/WhenUsingNamingConventions.ThenTheNamingConventionIsApplied.approved.txt index 2210c88f0..cc2a1ea1f 100644 --- a/tests/JustSaying.IntegrationTests/Fluent/Configuration/Approvals/WhenUsingNamingConventions.ThenTheNamingConventionIsApplied.approved.txt +++ b/tests/JustSaying.IntegrationTests/Fluent/Configuration/Approvals/WhenUsingNamingConventions.ThenTheNamingConventionIsApplied.approved.txt @@ -7,10 +7,10 @@ "QueueName": "beforequeue-simplemessage-afterqueue", "MiddlewareChain": [ "MessageContextAccessorMiddleware", - "ErrorHandlerMiddleware", "LoggingMiddleware", "StopwatchMiddleware", "SqsPostProcessorMiddleware", + "ErrorHandlerMiddleware", "HandlerInvocationMiddleware`1[JustSaying.TestingFramework.SimpleMessage]" ] } diff --git a/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenAMessageIsPublishedToATopicWithACustomName.Then_The_Message_Is_Handled.approved.txt b/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenAMessageIsPublishedToATopicWithACustomName.Then_The_Message_Is_Handled.approved.txt index bccbfee43..fe677262d 100644 --- a/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenAMessageIsPublishedToATopicWithACustomName.Then_The_Message_Is_Handled.approved.txt +++ b/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenAMessageIsPublishedToATopicWithACustomName.Then_The_Message_Is_Handled.approved.txt @@ -7,10 +7,10 @@ "QueueName": "integrationTestQueueName", "MiddlewareChain": [ "MessageContextAccessorMiddleware", - "ErrorHandlerMiddleware", "LoggingMiddleware", "StopwatchMiddleware", "SqsPostProcessorMiddleware", + "ErrorHandlerMiddleware", "HandlerInvocationMiddleware`1[JustSaying.TestingFramework.SimpleMessage]" ] } diff --git a/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenInterrogatingTheBus.Then_The_Interrogation_Result_Should_Be_Returned.approved.txt b/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenInterrogatingTheBus.Then_The_Interrogation_Result_Should_Be_Returned.approved.txt index b08c2ab7d..30e489fb6 100644 --- a/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenInterrogatingTheBus.Then_The_Interrogation_Result_Should_Be_Returned.approved.txt +++ b/tests/JustSaying.IntegrationTests/Fluent/Publishing/Approvals/WhenInterrogatingTheBus.Then_The_Interrogation_Result_Should_Be_Returned.approved.txt @@ -7,10 +7,10 @@ "QueueName": "integrationTestQueueName", "MiddlewareChain": [ "MessageContextAccessorMiddleware", - "ErrorHandlerMiddleware", "LoggingMiddleware", "StopwatchMiddleware", "SqsPostProcessorMiddleware", + "ErrorHandlerMiddleware", "HandlerInvocationMiddleware`1[JustSaying.TestingFramework.SimpleMessage]" ] } diff --git a/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Builder_Should_Put_User_Middlewares_In_The_Correct_Order.approved.txt b/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Builder_Should_Put_User_Middlewares_In_The_Correct_Order.approved.txt index 537bf5e97..216383026 100644 --- a/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Builder_Should_Put_User_Middlewares_In_The_Correct_Order.approved.txt +++ b/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Builder_Should_Put_User_Middlewares_In_The_Correct_Order.approved.txt @@ -7,10 +7,10 @@ "WhenApplyingDefaultMiddlewares+OuterTestMiddleware", "WhenApplyingDefaultMiddlewares+InnerTestMiddleware", "MessageContextAccessorMiddleware", - "ErrorHandlerMiddleware", "LoggingMiddleware", "StopwatchMiddleware", "SqsPostProcessorMiddleware", + "ErrorHandlerMiddleware", "WhenApplyingDefaultMiddlewares+AfterTestMiddleware", "HandlerInvocationMiddleware`1[JustSaying.TestingFramework.SimpleMessage]" ] diff --git a/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Defaults_Are_The_Defaults_For_Sure.approved.txt b/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Defaults_Are_The_Defaults_For_Sure.approved.txt index 1dff0a30f..c0c95c835 100644 --- a/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Defaults_Are_The_Defaults_For_Sure.approved.txt +++ b/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenApplyingDefaultMiddlewares.Then_The_Defaults_Are_The_Defaults_For_Sure.approved.txt @@ -5,10 +5,10 @@ "QueueName": "TestQueueName", "MiddlewareChain": [ "MessageContextAccessorMiddleware", - "ErrorHandlerMiddleware", "LoggingMiddleware", "StopwatchMiddleware", "SqsPostProcessorMiddleware", + "ErrorHandlerMiddleware", "HandlerInvocationMiddleware`1[JustSaying.TestingFramework.SimpleMessage]" ] } diff --git a/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenHandlerIsDeclaredAsExactlyOnce.Then_The_Handler_Only_Receives_The_Message_Once.approved.txt b/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenHandlerIsDeclaredAsExactlyOnce.Then_The_Handler_Only_Receives_The_Message_Once.approved.txt index 8084c1f71..1a5183dec 100644 --- a/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenHandlerIsDeclaredAsExactlyOnce.Then_The_Handler_Only_Receives_The_Message_Once.approved.txt +++ b/tests/JustSaying.IntegrationTests/Fluent/Subscribing/Approvals/WhenHandlerIsDeclaredAsExactlyOnce.Then_The_Handler_Only_Receives_The_Message_Once.approved.txt @@ -6,10 +6,10 @@ "MiddlewareChain": [ "ExactlyOnceMiddleware`1[JustSaying.TestingFramework.SimpleMessage]", "MessageContextAccessorMiddleware", - "ErrorHandlerMiddleware", "LoggingMiddleware", "StopwatchMiddleware", "SqsPostProcessorMiddleware", + "ErrorHandlerMiddleware", "HandlerInvocationMiddleware`1[JustSaying.TestingFramework.SimpleMessage]" ] } diff --git a/tests/JustSaying.IntegrationTests/Logging/LogContextTests.cs b/tests/JustSaying.IntegrationTests/Logging/LogContextTests.cs index 465860535..17582e269 100644 --- a/tests/JustSaying.IntegrationTests/Logging/LogContextTests.cs +++ b/tests/JustSaying.IntegrationTests/Logging/LogContextTests.cs @@ -122,7 +122,12 @@ public async Task HandleMessageFromQueueLogs_ShouldHaveContext(bool handlerShoul handleMessage.ShouldNotBeNull(); handleMessage.LogLevel.ShouldBe(level); - handleMessage.Exception?.Message.ShouldBe(exceptionMessage); + + if (exceptionMessage != null) + { + handleMessage.Exception.ShouldNotBeNull(); + handleMessage.Exception.Message.ShouldBe(exceptionMessage); + } var propertyMap = new Dictionary(handleMessage.Properties); propertyMap.ShouldContainKeyAndValue("Status", status);