Skip to content

CAMEL-23260: fix graceful shutdown for ServiceBus consumer (backport 4.18.x)#22444

Open
Croway wants to merge 1 commit intoapache:camel-4.18.xfrom
Croway:ci-issue-CAMEL-23260-4.18.x
Open

CAMEL-23260: fix graceful shutdown for ServiceBus consumer (backport 4.18.x)#22444
Croway wants to merge 1 commit intoapache:camel-4.18.xfrom
Croway:ci-issue-CAMEL-23260-4.18.x

Conversation

@Croway
Copy link
Copy Markdown
Contributor

@Croway Croway commented Apr 3, 2026

Summary

Backport of #22443 to camel-4.18.x.

  • 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

Test plan

  • New unit tests for deferShutdown(), getPendingExchangesSize(), doStop(), doShutdown()
  • All existing 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.
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.

1 participant