-
Notifications
You must be signed in to change notification settings - Fork 0
Use explicit message settlement via ServiceBusMessageActions #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
0975e2b
Add failing test
andreasohlund 44493f0
Add diagnostics for incorrect auto complete
andreasohlund bded1be
Use explicit settlement
andreasohlund cb5bc41
Wording
andreasohlund e6c0b17
Add first round of test
andreasohlund 39875bf
Consolidate test code
andreasohlund 58f937b
Add test for ErrorHandleResult.Handled
andreasohlund 1b3fa2e
Add test to check exposure of incoming message
andreasohlund e762bb4
Add test to check cancellation behavior
andreasohlund ef484fa
Add test to check body and headers
andreasohlund 60e0592
Cleanup
andreasohlund 4f163e1
Add todo
andreasohlund 5ef94c1
Add tests for upconverting
andreasohlund 160c6b0
Add comment for unique transport transaction in message processing tests
andreasohlund e835868
Remove support for legacy body format
andreasohlund afecf7b
Reguire message it to be set
andreasohlund 6a8851e
Use cancellation token none
andreasohlund ed63a37
Cleanup
andreasohlund abf6dd7
More cleanup
andreasohlund 8c0cdd4
Log when message without message id is dlq'd
andreasohlund 0fbd59d
Silence PS0004 in tests
andreasohlund c8f0450
Include scopes
andreasohlund 885e451
Remove handled todos
andreasohlund 82ea87e
Formatting
andreasohlund b81d4c8
Upconvert content type as well to align with the transport
andreasohlund 2f41e86
Support deadlettering to be requested via onError
andreasohlund c4cbc67
Add test for message abandonment when onError throws an exception
andreasohlund 9bc94cc
Enhance logging for dead lettering and add test coverage for message …
andreasohlund 450859a
Cleanup
andreasohlund 3d7741c
Clarify todo
andreasohlund b52eee6
Use the MS FakeLogger
andreasohlund 401f720
More details
andreasohlund 83c569a
Refine dead letter logging message for clarity
andreasohlund 6e81c92
Log when processing and on error cancelled
andreasohlund 06acb48
Add test to ensure header mutations are not propagated from onMessage…
andreasohlund c3e3927
Cleanup todos
andreasohlund b1b9b1c
DLQ if header extraction fails
andreasohlund f198813
Clone header
andreasohlund 029be0e
Include context creating in try catch
andreasohlund e63af94
Dead letter message if on error fails with non-transient exception
andreasohlund 111a98e
Support requesting DLQ from recoverability policy
andreasohlund 2bea8e1
Approve api
andreasohlund f5ce9de
Revert test code
andreasohlund e864ed5
Remove demo
andreasohlund 7a2a313
Truncate dlq message and reason to 1024 to make it less likely go ove…
andreasohlund 08f0a75
Clarify code with comment on message header usage in error handling
andreasohlund edd2e60
Refactor dead letter request test to simulate exception handling and …
andreasohlund 6d63269
Formatting
andreasohlund 1186e0e
Refactor exception handling in dead letter request test for clarity a…
andreasohlund c34c038
Check that we swallow exceptions when dead lettering
andreasohlund 0df2ece
Make sure auto generated message id is persisted on failure
andreasohlund c007b24
Use null or whitespace
andreasohlund 463bd5c
SafeAbandon
andreasohlund 549e890
Make sure auto generated message id is used
andreasohlund 2582c7a
Fix bug in test storage
andreasohlund 70eba9d
Use nsb header key for message id when storing auto generated message id
andreasohlund 587e782
Cache message ids that have been failes during complete and complete …
andreasohlund 07ab30b
Refactor logging to use `LoggerMessage` source generator for improved…
danielmarbach a413996
Update log level from Debug to Warning for message failure scenarios
danielmarbach 4b7a1fd
Use `Guid.CreateVersion7` for generating `nativeMessageId` in message…
danielmarbach d92b0db
Simplify message body initialization by replacing `BinaryData.FromByt…
danielmarbach 120837f
Replace `Guid.CreateVersion7` with `GuidHelper.CreateVersion8` for de…
danielmarbach ffdfc8b
Simplify `nativeMessageId` initialization using a ternary operator fo…
danielmarbach 4d816e4
Replace `Assert` methods with `Assert.That` for consistency and impro…
danielmarbach a938616
Remove extra whitespace in `[ServiceBusTrigger]` attribute for consis…
danielmarbach d6c66a5
Refactor `PipelineInvokingMessageProcessor` to use primary constructo…
danielmarbach a28cdc2
Provide dead letter API as an extension of RecoverabilityActions to a…
andreasohlund f49ae61
Formatting
andreasohlund File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/NServiceBus.AzureFunctions.AzureServiceBus/DeadLetterMessage.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| namespace NServiceBus.AzureFunctions.AzureServiceBus; | ||
|
|
||
| using Pipeline; | ||
| using Transport; | ||
|
|
||
| public sealed class DeadLetterMessage : RecoverabilityAction | ||
| { | ||
| internal DeadLetterMessage(string deadLetterReason, string deadLetterErrorDescription, Dictionary<string, object>? propertiesToModify = null) => | ||
| deadLetterRequest = new DeadLetterRequest(deadLetterReason, deadLetterErrorDescription, propertiesToModify); | ||
|
|
||
| internal DeadLetterMessage(Exception exception) => | ||
| deadLetterRequest = new DeadLetterRequest(exception); | ||
|
|
||
| public override IReadOnlyCollection<IRoutingContext> GetRoutingContexts(IRecoverabilityActionContext context) | ||
| { | ||
| context.Extensions.Get<TransportTransaction>().Set(deadLetterRequest); | ||
| return []; | ||
| } | ||
|
|
||
| public override ErrorHandleResult ErrorHandleResult => ErrorHandleResult.Handled; | ||
|
|
||
| readonly DeadLetterRequest deadLetterRequest; | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/NServiceBus.AzureFunctions.AzureServiceBus/DeadLetterRequest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| namespace NServiceBus.AzureFunctions.AzureServiceBus; | ||
|
|
||
| class DeadLetterRequest(string deadLetterReason, string deadLetterErrorDescription, Dictionary<string, object>? propertiesToModify = null) | ||
| { | ||
| public string DeadLetterReason { get; } = Truncate(deadLetterReason, 1024); | ||
| public string DeadLetterErrorDescription { get; } = Truncate(deadLetterErrorDescription, 1024); | ||
| public Dictionary<string, object> PropertiesToModify { get; } = propertiesToModify ?? []; | ||
|
|
||
| public DeadLetterRequest(Exception exception, Dictionary<string, object>? propertiesToModify = null) : this( | ||
| $"{exception.GetType().FullName} - {exception.Message}", | ||
| exception.StackTrace ?? "No stack trace available", | ||
| propertiesToModify) | ||
| { | ||
| } | ||
|
|
||
| static string Truncate(string value, int maxLength) => string.IsNullOrEmpty(value) ? value : value.Length <= maxLength ? value : value[..maxLength]; | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/NServiceBus.AzureFunctions.AzureServiceBus/GuidHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| namespace NServiceBus.AzureFunctions.AzureServiceBus; | ||
|
|
||
| using System; | ||
| using System.Buffers.Binary; | ||
|
|
||
| /// <summary> | ||
| /// Provides helper methods for working with <see cref="Guid"/>. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Inspired by <a href="https://github.com/bgrainger/NGuid">NGuid</a> by Bradley Grainger, | ||
| /// used under the <a href="https://github.com/bgrainger/NGuid/blob/master/LICENSE">MIT License</a>. | ||
| /// </remarks> | ||
| static class GuidHelper | ||
| { | ||
| /// <summary> | ||
| /// Creates a Version 8 UUID with a v7-style layout: <paramref name="timestamp"/> as Unix | ||
| /// milliseconds in bytes 0–7 (time-sortable, stable across redeliveries) and | ||
| /// <paramref name="sequenceNumber"/> in bytes 8–15, both big-endian. | ||
| /// </summary> | ||
| public static Guid CreateVersion8(DateTimeOffset timestamp, long sequenceNumber) | ||
| { | ||
| Span<byte> guidBytes = stackalloc byte[16]; | ||
| BinaryPrimitives.WriteInt64BigEndian(guidBytes, timestamp.ToUnixTimeMilliseconds()); | ||
| BinaryPrimitives.WriteInt64BigEndian(guidBytes[8..], sequenceNumber); | ||
| guidBytes[6] = (byte)(0x80 | (guidBytes[6] & 0xF)); | ||
| guidBytes[8] = (byte)(0x80 | (guidBytes[8] & 0x3F)); | ||
| return new Guid(guidBytes, bigEndian: true); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.