Allow configuring ServiceBusProcessorOptions for Azure Service Bus listeners#3286
Closed
jorik wants to merge 1 commit into
Closed
Allow configuring ServiceBusProcessorOptions for Azure Service Bus listeners#3286jorik wants to merge 1 commit into
jorik wants to merge 1 commit into
Conversation
Member
|
Thanks @jorik — this is great, and the feature is being merged. I've opened #3293 which supersedes this PR: it carries your commit verbatim (same authorship preserved) and adds one extra commit that pins Closing in favor of #3293. Full credit to you for the ServiceBus processor options feature. 🙏 |
jeremydmiller
added a commit
that referenced
this pull request
Jul 5, 2026
Configure ServiceBusProcessorOptions for Azure Service Bus listeners (supersedes #3286)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
The Azure Service Bus transport currently creates the inline listener's
ServiceBusProcessorwith no options, soServiceBusProcessorOptions.MaxAutoLockRenewalDurationis stuck at the Azure SDK default of five minutes. Any inline handler that runs longer than five minutes loses the message lock. When Wolverine then tries to complete the message,AzureServiceBusEnvelope.CompleteAsyncswallows the "The lock supplied is invalid"ServiceBusException, so the ack silently fails and Azure Service Bus redelivers the message — duplicate work untilMaxDeliveryCountfinally dead-letters it.There was previously no way to configure the underlying
ServiceBusProcessorOptionsat all. Jeremy invited this contribution in #2112 (originally #2110): "adding the ability to configure the ServiceBusProcessor objects would be a simple pull request."What this adds
A
ConfigureProcessor(Action<ServiceBusProcessorOptions>)fluent method on both:AzureServiceBusQueueListenerConfiguration.ConfigureProcessor(Action<ServiceBusProcessorOptions>)AzureServiceBusSubscriptionListenerConfiguration.ConfigureProcessor(Action<ServiceBusProcessorOptions>)The action is stored on the endpoint (
AzureServiceBusEndpoint.ConfigureProcessor) following the existingConfigureQueue(Action<CreateQueueOptions>)/DelayedEndpointConfiguration.add(...)pattern. It is applied when the inlineServiceBusProcessoris created for both the queue and topic-subscription paths inAzureServiceBusTransport.Listening.csvia a newBuildProcessorOptionshelper.Typical use — raising the lock-renewal window for long-running inline handlers:
Honored vs. reserved properties
BuildProcessorOptionsinvokes the user callback first, then re-assertsReceiveMode = ServiceBusReceiveMode.PeekLock. The inline listener (InlineAzureServiceBusListener) completes, defers, and dead letters messages against the message lock, soReceiveAndDeletewould break acknowledgement, deferral, and dead lettering.ReceiveModeis therefore the one property the transport reserves; every otherServiceBusProcessorOptionsproperty (includingMaxAutoLockRenewalDuration,PrefetchCount,MaxConcurrentCalls,AutoCompleteMessages, etc.) is honored as configured.Scope
Scoped to the non-session inline processor paths. Session-based listeners (
RequireSessions()) do not use aServiceBusProcessorat all — they useAcceptNextSessionAsyncplus a manualServiceBusSessionReceiverloop (AzureServiceBusSessionListener/SessionSpecificListener), soServiceBusProcessorOptions/ServiceBusSessionProcessorOptionsdon't apply there. Extending session configuration would be a separate change against a different code path and is intentionally left out.Tests
Added
configuring_processor_options.cs(broker-free config-level tests, following the existingAzureServiceBusTransportTestspattern):BuildProcessorOptionsapplies the configured action (MaxAutoLockRenewalDuration,PrefetchCount)BuildProcessorOptionsre-assertsPeekLockeven when the user setsReceiveAndDeleteBuildProcessorOptionsproduces validPeekLockoptions when no action is configuredRan locally on
net10.0(the full ASB integration suite needs the emulator/a live namespace, which I did not run):configuring_processor_optionstests: 5 passedAzureServiceBusTransportTests+AzureServiceBusEndpointUriTests: 27 passedWolverine.AzureServiceBusandWolverine.AzureServiceBus.Testsboth build clean (0 warnings, 0 errors)Docs
Added a "Configuring the ServiceBusProcessor" section to
docs/guide/messaging/transports/azureservicebus/listening.mdwith aMaxAutoLockRenewalDurationsample sourced fromDocumentationSamples.cs(regionsample_configuring_azure_service_bus_processor_options), plus a note on the reservedReceiveModeand the session-listener exclusion. (I couldn't runmdsnippetslocally — it isn't installed in the environment — so the snippet source line link may need a regen pass.)🤖 Generated with Claude Code