fix: adapt Azure Service Bus MessageBus to two-phase dispose lifecycle#77
Conversation
- Add ShutdownAsync override for StopProcessingAsync - Add CleanupAsync override for processor/sender/client disposal - Handle OperationCanceledException in OnMessageAsync - Remove ad-hoc Dispose/DisposeAsync - Depends on FoundatioFx/Foundatio#492
There was a problem hiding this comment.
Pull request overview
Adapts AzureServiceBusMessageBus to Foundatio’s new two-phase disposal lifecycle (shutdown/drain first, then cleanup), and updates the Azure Service Bus test suite to exercise the new async dispose semantics.
Changes:
- Replace ad-hoc
Dispose/DisposeAsync+ private cleanup helpers withShutdownAsync(drain) andCleanupAsync(dispose resources). - Update message handling to catch
OperationCanceledExceptionduring dispose. - Extend/adjust Azure Service Bus message bus tests to cover new dispose behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Foundatio.AzureServiceBus.Tests/Messaging/AzureServiceBusMessageBusTests.cs | Updates/extends base test overrides to validate async dispose lifecycle behavior for the ASB bus. |
| src/Foundatio.AzureServiceBus/Messaging/AzureServiceBusMessageBus.cs | Implements two-phase dispose (ShutdownAsync + CleanupAsync) and tweaks message processing error handling during disposal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4ea90ee to
ed06a7d
Compare
…nAsync, add pre-lock null check
There was a problem hiding this comment.
Pull request overview
This PR updates the Azure Service Bus message bus implementation to align with Foundatio’s new two-phase dispose lifecycle (graceful shutdown/drain followed by resource cleanup), and updates tests/packages accordingly.
Changes:
- Refactors
AzureServiceBusMessageBuscleanup to use lifecycle overrides instead of ad-hocDispose/DisposeAsyncimplementations. - Adjusts message handling during disposal by rethrowing
OperationCanceledException(to avoid message auto-complete). - Updates Foundatio/Foundatio.TestHarness package references and refreshes test coverage around disposal behaviors.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Foundatio.AzureServiceBus/Messaging/AzureServiceBusMessageBus.cs |
Moves disposal logic into lifecycle overrides and tweaks cancellation behavior in message processing. |
src/Foundatio.AzureServiceBus/Foundatio.AzureServiceBus.csproj |
Bumps Foundatio dependency to 13.0.0-beta5.2. |
tests/Directory.Build.props |
Bumps Foundatio.TestHarness dependency to 13.0.0-beta5.2. |
tests/Foundatio.AzureServiceBus.Tests/Messaging/AzureServiceBusMessageBusTests.cs |
Updates/expands test overrides to match new disposal lifecycle expectations. |
samples/Foundatio.AzureServiceBus.Subscribe/Program.cs |
Minor formatting change in catch block. |
samples/Foundatio.AzureServiceBus.Dequeue/Program.cs |
Minor formatting change in catch block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Dependencies
Test plan