Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Mar 10, 2024
1 parent bbf982f commit aa1b737
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 37 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ serilogTracing.EnableMessageTracing();
ProcessingEndpoint: SerilogTestsStartHandler,
ReplyToAddress: SerilogTestsStartHandler,
SourceContext: StartHandler,
StartTime: DateTimeOffset_2,
TimeSent: DateTimeOffset_3
StartTime: DateTimeOffset_1,
TimeSent: DateTimeOffset_2
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/BehaviorThatThrows/TheHandlerThatLogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
IHandleMessages<StartBehaviorThatThrows>
{
public Task Handle(StartBehaviorThatThrows message, HandlerContext context) =>
Task.CompletedTask;
Task.Delay(1100, context.CancellationToken);
}
4 changes: 2 additions & 2 deletions src/Tests/Handler/TheHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
public TheHandler(ManualResetEvent resetEvent) =>
this.resetEvent = resetEvent;

public Task Handle(StartHandler message, HandlerContext context)
public async Task Handle(StartHandler message, HandlerContext context)
{
await Task.Delay(1100, context.CancellationToken);
context.LogInformation("Hello from {@Handler}.");
resetEvent.Set();
return Task.CompletedTask;
}
}
4 changes: 2 additions & 2 deletions src/Tests/HandlerGeneric/TheHandlerThatThrows.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
public class GenericHandler(ManualResetEvent @event) :
IHandleMessages<StartGenericHandler<string>>
{
public Task Handle(StartGenericHandler<string> message, HandlerContext context)
public async Task Handle(StartGenericHandler<string> message, HandlerContext context)
{
await Task.Delay(1100, context.CancellationToken);
context.LogInformation("Hello from {@Handler}.");
@event.Set();
return Task.CompletedTask;
}
}
4 changes: 2 additions & 2 deletions src/Tests/HandlerThatLogs/TheHandlerThatLogs.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
public class TheHandlerThatLogs(ManualResetEvent @event) :
IHandleMessages<StartHandlerThatLogs>
{
public Task Handle(StartHandlerThatLogs message, HandlerContext context)
public async Task Handle(StartHandlerThatLogs message, HandlerContext context)
{
await Task.Delay(1100, context.CancellationToken);
var logger = LogManager.GetLogger<TheHandlerThatThrows>();
logger.Error("The message", new());
@event.Set();
return Task.CompletedTask;
}
}
5 changes: 4 additions & 1 deletion src/Tests/HandlerThatThrows/TheHandlerThatThrows.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
public class TheHandlerThatThrows :
IHandleMessages<StartHandlerThatThrows>
{
public Task Handle(StartHandlerThatThrows message, HandlerContext context) =>
public async Task Handle(StartHandlerThatThrows message, HandlerContext context)
{
await Task.Delay(1100, context.CancellationToken);
throw new();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
public class HandlerUsingContextLogger :
IHandleMessages<StartHandlerUsingContextLogger>
{
public Task Handle(StartHandlerUsingContextLogger message, HandlerContext context)
public async Task Handle(StartHandlerUsingContextLogger message, HandlerContext context)
{
await Task.Delay(1100, context.CancellationToken);
context.LogError("The message", new Exception());
return Task.CompletedTask;
}
}
50 changes: 25 additions & 25 deletions src/Tests/IntegrationTests.HandlerThatThrows.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
"HResult": -2146233088,
"Message": Exception of type 'System.Exception' was thrown.,
"Source": Tests,
"TargetSite": System.Threading.Tasks.Task Handle(StartHandlerThatThrows, NServiceBus.IMessageHandlerContext)
"TargetSite": Void MoveNext()
}
},
HandlerFailureTime: DateTimeOffset_3,
HandlerStartTime: DateTimeOffset_3,
HandlerStartTime: DateTimeOffset_4,
HandlerType: TheHandlerThatThrows,
IncomingMessage: {
TypeTag: StartHandlerThatThrows,
Expand All @@ -85,7 +85,7 @@
ProcessingEndpoint: SerilogTestsStartHandlerThatThrows,
ReplyToAddress: SerilogTestsStartHandlerThatThrows,
SourceContext: NServiceBus.ImmediateRetry,
TimeSent: DateTimeOffset_4
TimeSent: DateTimeOffset_5
}
},
{
Expand All @@ -102,8 +102,8 @@
Elements: {
"Message type": StartHandlerThatThrows,
"Handler type": TheHandlerThatThrows,
"Handler start time": DateTimeOffset_5,
"Handler failure time": DateTimeOffset_6,
"Handler start time": DateTimeOffset_6,
"Handler failure time": DateTimeOffset_7,
"Handler canceled": false,
"ExceptionLogState": {
TypeTag: ExceptionLogState
Expand All @@ -116,11 +116,11 @@
"HResult": -2146233088,
"Message": Exception of type 'System.Exception' was thrown.,
"Source": Tests,
"TargetSite": System.Threading.Tasks.Task Handle(StartHandlerThatThrows, NServiceBus.IMessageHandlerContext)
"TargetSite": Void MoveNext()
}
},
HandlerFailureTime: DateTimeOffset_7,
HandlerStartTime: DateTimeOffset_7,
HandlerFailureTime: DateTimeOffset_8,
HandlerStartTime: DateTimeOffset_9,
HandlerType: TheHandlerThatThrows,
IncomingMessage: {
TypeTag: StartHandlerThatThrows,
Expand All @@ -140,7 +140,7 @@
ProcessingEndpoint: SerilogTestsStartHandlerThatThrows,
ReplyToAddress: SerilogTestsStartHandlerThatThrows,
SourceContext: NServiceBus.DelayedRetry,
TimeSent: DateTimeOffset_4
TimeSent: DateTimeOffset_5
}
},
{
Expand All @@ -150,16 +150,16 @@
ContentType: text/xml,
ConversationId: Guid_1,
CorrelationId: Guid_2,
DeliverAt: DateTimeOffset_8,
DeliverAt: DateTimeOffset_10,
ExceptionDetail: {
Elements: {
"Type": System.Exception,
"Data": {
Elements: {
"Message type": StartHandlerThatThrows,
"Handler type": TheHandlerThatThrows,
"Handler start time": DateTimeOffset_9,
"Handler failure time": DateTimeOffset_10,
"Handler start time": DateTimeOffset_11,
"Handler failure time": DateTimeOffset_12,
"Handler canceled": false,
"ExceptionLogState": {
TypeTag: ExceptionLogState
Expand All @@ -172,11 +172,11 @@
"HResult": -2146233088,
"Message": Exception of type 'System.Exception' was thrown.,
"Source": Tests,
"TargetSite": System.Threading.Tasks.Task Handle(StartHandlerThatThrows, NServiceBus.IMessageHandlerContext)
"TargetSite": Void MoveNext()
}
},
HandlerFailureTime: DateTimeOffset_11,
HandlerStartTime: DateTimeOffset_11,
HandlerFailureTime: DateTimeOffset_13,
HandlerStartTime: DateTimeOffset_14,
HandlerType: TheHandlerThatThrows,
IncomingMessage: {
TypeTag: StartHandlerThatThrows,
Expand All @@ -196,9 +196,9 @@
ProcessingEndpoint: SerilogTestsStartHandlerThatThrows,
ReplyToAddress: SerilogTestsStartHandlerThatThrows,
Retries: 1,
Retries.Timestamp: DateTimeOffset_12,
Retries.Timestamp: DateTimeOffset_15,
SourceContext: NServiceBus.ImmediateRetry,
TimeSent: DateTimeOffset_4
TimeSent: DateTimeOffset_5
}
},
{
Expand All @@ -208,16 +208,16 @@
ContentType: text/xml,
ConversationId: Guid_1,
CorrelationId: Guid_2,
DeliverAt: DateTimeOffset_8,
DeliverAt: DateTimeOffset_10,
ExceptionDetail: {
Elements: {
"Type": System.Exception,
"Data": {
Elements: {
"Message type": StartHandlerThatThrows,
"Handler type": TheHandlerThatThrows,
"Handler start time": DateTimeOffset_13,
"Handler failure time": DateTimeOffset_14,
"Handler start time": DateTimeOffset_16,
"Handler failure time": DateTimeOffset_17,
"Handler canceled": false,
"ExceptionLogState": {
TypeTag: ExceptionLogState
Expand All @@ -230,11 +230,11 @@
"HResult": -2146233088,
"Message": Exception of type 'System.Exception' was thrown.,
"Source": Tests,
"TargetSite": System.Threading.Tasks.Task Handle(StartHandlerThatThrows, NServiceBus.IMessageHandlerContext)
"TargetSite": Void MoveNext()
}
},
HandlerFailureTime: DateTimeOffset_15,
HandlerStartTime: DateTimeOffset_15,
HandlerFailureTime: DateTimeOffset_18,
HandlerStartTime: DateTimeOffset_19,
HandlerType: TheHandlerThatThrows,
IncomingMessage: {
TypeTag: StartHandlerThatThrows,
Expand All @@ -254,9 +254,9 @@
ProcessingEndpoint: SerilogTestsStartHandlerThatThrows,
ReplyToAddress: SerilogTestsStartHandlerThatThrows,
Retries: 1,
Retries.Timestamp: DateTimeOffset_12,
Retries.Timestamp: DateTimeOffset_15,
SourceContext: NServiceBus.MoveToError,
TimeSent: DateTimeOffset_4
TimeSent: DateTimeOffset_5
}
}
]
Expand Down

0 comments on commit aa1b737

Please sign in to comment.