Skip to content

Fix AutoPurgeOnStartup for session-enabled ASB subscriptions#2284

Merged
jeremydmiller merged 1 commit intomainfrom
fix/2283-asb-subscription-session-purge
Mar 11, 2026
Merged

Fix AutoPurgeOnStartup for session-enabled ASB subscriptions#2284
jeremydmiller merged 1 commit intomainfrom
fix/2283-asb-subscription-session-purge

Conversation

@jeremydmiller
Copy link
Member

Summary

  • AzureServiceBusSubscription.PurgeAsync was using ServiceBusClient.CreateReceiver which throws when sessions are enabled on the subscription
  • Now checks Options.RequiresSession and uses AcceptNextSessionAsync(topicName, subscriptionName) for session-enabled subscriptions, matching the existing pattern in AzureServiceBusQueue.PurgeAsync
  • Also aligned error logging level to LogDebug (consistent with queue purge behavior)

Test plan

  • Added Bug_2283_purge_session_subscription end-to-end tests that:
    • Verify host starts successfully with AutoPurgeOnStartup + session-enabled subscription
    • Send and receive messages through the session-enabled subscription
    • Start a second host against the same subscription to validate purge works when messages exist

Closes #2283

🤖 Generated with Claude Code

…tions

AzureServiceBusSubscription.PurgeAsync was using CreateReceiver which fails
when sessions are enabled. Now checks Options.RequiresSession and uses
AcceptNextSessionAsync for session-enabled subscriptions, matching the
existing pattern in AzureServiceBusQueue.PurgeAsync.

Closes #2283

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service Bus Configured with AutoPurgeOnStartup Can't Configure Topics With Sessions Enabled

1 participant