-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Include SubQueue option for Processor #20719
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,9 @@ public ReceiverManager( | |
| { | ||
| ReceiveMode = ProcessorOptions.ReceiveMode, | ||
| PrefetchCount = ProcessorOptions.PrefetchCount, | ||
| // Pass None for subqueue since the subqueue has already | ||
| // been taken into account when computing the EntityPath of the processor. | ||
| SubQueue = SubQueue.None | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not technically necessary (since None is the default), but I included it to help document why the option is not passed to the receiver.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this helpful to follow the rationale. |
||
| }; | ||
| _maxReceiveWaitTime = ProcessorOptions.MaxReceiveWaitTime; | ||
| _plugins = plugins; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -775,5 +775,59 @@ Task processErrorAsync(ProcessErrorEventArgs args) | |
| } | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task ProcessDlq() | ||
| { | ||
| await using (var scope = await ServiceBusScope.CreateWithQueue(enablePartitioning: false, enableSession: false)) | ||
| { | ||
| await using var client = CreateClient(); | ||
| var sender = client.CreateSender(scope.QueueName); | ||
| int messageCount = 10; | ||
|
|
||
| // send some messages | ||
| await sender.SendMessagesAsync(GetMessages(messageCount)); | ||
|
|
||
| // receive the messages | ||
| var receiver = client.CreateReceiver(scope.QueueName); | ||
| int remaining = messageCount; | ||
|
|
||
| // move the messages to the DLQ | ||
| while (remaining > 0) | ||
| { | ||
| var messages = await receiver.ReceiveMessagesAsync(remaining); | ||
| remaining -= messages.Count; | ||
| foreach (ServiceBusReceivedMessage message in messages) | ||
| { | ||
| await receiver.DeadLetterMessageAsync(message); | ||
| } | ||
| } | ||
|
|
||
| // process the DLQ | ||
| await using var processor = client.CreateProcessor(scope.QueueName, new ServiceBusProcessorOptions | ||
| { | ||
| SubQueue = SubQueue.DeadLetter | ||
| }); | ||
|
|
||
| int receivedCount = 0; | ||
| var tcs = new TaskCompletionSource<bool>(); | ||
|
|
||
| Task ProcessMessage(ProcessMessageEventArgs args) | ||
| { | ||
| var ct = Interlocked.Increment(ref receivedCount); | ||
| if (ct == messageCount) | ||
| { | ||
| tcs.SetResult(true); | ||
| } | ||
| return Task.CompletedTask; | ||
| } | ||
| processor.ProcessMessageAsync += ProcessMessage; | ||
| processor.ProcessErrorAsync += ExceptionHandler; | ||
|
|
||
| await processor.StartProcessingAsync(); | ||
| await tcs.Task; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we include a cancellation token timeout here to ensure that the test doesn't hang if the right number of messages aren't read?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The approach we use is to just let the tests timeout after 5 minutes. We could add a shorter timeout for some of these tests but I'm not sure it would be worth it. |
||
| await processor.StopProcessingAsync(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
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 was erroneously left over from a previous beta.