-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Storage] Queues - Failed message handler #17001
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7d7b268
wip
kasobol-msft 74a3175
export api.
kasobol-msft f8d31c8
Merge remote-tracking branch 'upstream/master' into failed-message-ha…
kasobol-msft f0755e0
that works.
kasobol-msft f91dc77
handle peeked messages
kasobol-msft fe4a3ce
api
kasobol-msft 6185993
merge master
kasobol-msft 2b92bbb
post merge.
kasobol-msft cf90918
propagate queueclient.
kasobol-msft 7fb3036
merge upstream/master
kasobol-msft dc3e36a
Merge remote-tracking branch 'upstream/master' into failed-message-ha…
kasobol-msft e489930
fire and forget callback.
kasobol-msft 415e4fd
tweaks.
kasobol-msft 31279da
merge master.
kasobol-msft 87c5c9e
re-record.
kasobol-msft 4d5eeac
hack core temporarily.
kasobol-msft 451c330
use event hander from core.
kasobol-msft 3f8aeec
revert test change.
kasobol-msft 13cf452
remove direct core reference from test package.
kasobol-msft af47e2c
that won't be necessary.
kasobol-msft 7cad45d
more tests.
kasobol-msft 918349f
readme.
kasobol-msft ea14fa1
whitespace.
kasobol-msft a078234
merge master
kasobol-msft 27fb680
some pr feedback.
kasobol-msft 8eb362e
api
kasobol-msft 23c5214
get parent queue service.
kasobol-msft 40e56ec
use project ref.
kasobol-msft 30aad88
readme tweaks.
kasobol-msft 13d53d5
renaming.
kasobol-msft 6585e9f
misc.
kasobol-msft 46f69cb
protected onevent thing.
kasobol-msft 59c3d24
merge master.
kasobol-msft 523d886
post merge.
kasobol-msft 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 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 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 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
65 changes: 65 additions & 0 deletions
65
sdk/storage/Azure.Storage.Queues/samples/Sample03_MessageEncoding.cs
This file contains 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,65 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Storage.Queues.Models; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Storage.Queues.Samples.Tests | ||
{ | ||
public class Sample03_MessageEncoding : SampleTest | ||
{ | ||
[Test] | ||
public void ConfigureMessageEncodingAsync() | ||
{ | ||
var connectionString = ConnectionString; | ||
var queueName = "foo"; | ||
#region Snippet:Azure_Storage_Queues_Samples_Sample03_MessageEncoding_ConfigureMessageEncodingAsync | ||
|
||
QueueClientOptions queueClientOptions = new QueueClientOptions() | ||
{ | ||
MessageEncoding = QueueMessageEncoding.Base64 | ||
}; | ||
|
||
QueueClient queueClient = new QueueClient(connectionString, queueName, queueClientOptions); | ||
#endregion | ||
} | ||
|
||
[Test] | ||
public void MessageDecodingFailedHandlerAsync() | ||
{ | ||
var connectionString = ConnectionString; | ||
var queueName = "foo"; | ||
#region Snippet:Azure_Storage_Queues_Samples_Sample03_MessageEncoding_MessageDecodingFailedHandlerAsync | ||
|
||
QueueClientOptions queueClientOptions = new QueueClientOptions() | ||
{ | ||
MessageEncoding = QueueMessageEncoding.Base64 | ||
}; | ||
|
||
queueClientOptions.MessageDecodingFailed += async (QueueMessageDecodingFailedEventArgs args) => | ||
{ | ||
if (args.PeekedMessage != null) | ||
{ | ||
Console.WriteLine($"Invalid message has been peeked, message id={args.PeekedMessage.MessageId} body={args.PeekedMessage.Body}"); | ||
} | ||
else if (args.ReceivedMessage != null) | ||
{ | ||
Console.WriteLine($"Invalid message has been received, message id={args.ReceivedMessage.MessageId} body={args.ReceivedMessage.Body}"); | ||
|
||
if (args.RunSynchronously) | ||
{ | ||
args.Queue.DeleteMessage(args.ReceivedMessage.MessageId, args.ReceivedMessage.PopReceipt); | ||
} | ||
else | ||
{ | ||
await args.Queue.DeleteMessageAsync(args.ReceivedMessage.MessageId, args.ReceivedMessage.PopReceipt); | ||
} | ||
} | ||
}; | ||
|
||
QueueClient queueClient = new QueueClient(connectionString, queueName, queueClientOptions); | ||
#endregion | ||
} | ||
} | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is similar to #16437 .
While working on downstream stuff I figured that this will be extremely useful if someone wants to jump from
InvalidMessageEventArgs.QueueClient
to some other queue (i.e. poison queue).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice. Should we add an extension method in WebJobs to get the poison queue for a QueueClient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. In webjobs PR though.