Skip to content

CAMEL-23260: fix graceful shutdown for ServiceBus consumer#22443

Open
Croway wants to merge 1 commit intoapache:mainfrom
Croway:ci-issue-CAMEL-23260
Open

CAMEL-23260: fix graceful shutdown for ServiceBus consumer#22443
Croway wants to merge 1 commit intoapache:mainfrom
Croway:ci-issue-CAMEL-23260

Conversation

@Croway
Copy link
Copy Markdown
Contributor

@Croway Croway commented Apr 3, 2026

Summary

  • Implement ShutdownAware in ServiceBusConsumer to defer shutdown until in-flight exchanges complete their ACK/NACK to Azure Service Bus
  • Change doStop() from client.close() to client.stop() to keep the AMQP connection alive for in-flight message acknowledgement
  • Add doShutdown() to close the client only after all exchanges have drained
  • Track in-flight exchanges with AtomicInteger counter, decremented in try/finally blocks in onComplete()/onFailure()

Test plan

  • New unit tests for deferShutdown(), getPendingExchangesSize(), doStop(), doShutdown()
  • All existing 17 consumer tests continue to pass
  • mvn verify passes on camel-azure-servicebus module

Implement ShutdownAware in ServiceBusConsumer to defer shutdown
until in-flight exchanges complete their ACK/NACK to Azure Service Bus.
Previously, doStop() immediately closed the client, causing
RejectedExecutionException and message redelivery when SIGTERM
was received during message processing.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants