Croway opened a new pull request, #30800: URL: https://github.com/apache/camel/pull/30800
JIRA: [CAMEL-27009](https://issues.apache.org/jira/browse/CAMEL-27009) ## Problem When the suspend or stop of a consumer blocks in a client call that waits for a broker that stopped answering (and ignores the interrupt), `CamelContext.stop()` and a route stop wait for it past the shutdown timeout: the graceful shutdown task holds the consumer's service lock, and the forced shutdown (or `RouteService.stopChildServices`) waits for the same lock. The log only says "Timeout occurred during graceful shutdown. Forcing the routes to be shutdown now", then nothing until the call returns. Found with fault-injection tests: camel-spring-rabbitmq waits for `basic.cancel-ok` up to the client's `channelRpcTimeout` (10 minutes by default), camel-jms with ActiveMQ Artemis for its `callTimeout` (30 s). As agreed on the JIRA, `stop()` stays synchronous in core (as decided in CAMEL-7623 and CAMEL-13310), and the components where the call blocks bound it. The options considered and why they were rejected are in the JIRA description. ## Changes **camel-core** (`DefaultShutdownStrategy`) - When the timeout elapses while the shutdown task is still inside a consumer's suspend or stop, one WARN names the route, the (sanitized) endpoint, and the frames where the call waits. The in-progress record lives on the task, so concurrent shutdowns stay isolated (CAMEL-26449). No other behaviour change. - Javadoc of `DefaultShutdownStrategy` and `ShutdownStrategy.setTimeout`, and `graceful-shutdown.adoc`: the timeout is when Camel switches to the forced shutdown; it does not bound a consumer's suspend or stop. **camel-jms** (`JmsConsumer`) and **camel-spring-rabbitmq** (`SpringRabbitMQConsumer`, DMLC and SMLC) - Suspend and stop of the listener container wait at most the `shutdownAwaitTermination` of the `ExecutorServiceManager` (10 s by default, as CAMEL-27010 does for camel-mongodb), or until the waiting thread is interrupted (as the graceful shutdown does on timeout). No new option. - On timeout: one WARN, the listener container is detached and stopped/destroyed in the background, and a resume or start creates a new one (the WARN "Probably there was a timeout during the Suspend operation. Please restart your consumer route" is gone in both components). - When the container stops in time, the outcome is unchanged (the stop now runs on a component thread pool: camel-jms `AsyncStartStopListener`, new camel-spring-rabbitmq `SpringRabbitMQStopListenerContainer`). - camel-jms: a suspend or stop from a listener thread of the same container (such as a route policy) still runs inline; `asyncStopListener=true` is unchanged. - camel-spring-rabbitmq: a generated queue name is kept for the new container; the declaring connection listener is replaced instead of leaked. **Docs**: component pages (and catalog copies), upgrade guide 4.24 entry. ## Tests - `DefaultShutdownStrategyBlockedConsumerTest` (camel-core, `@Isolated` because `ShutdownWaitingAtTest` rewrites the same log4j logger): context stop and route stop with a consumer whose suspend or stop blocks and ignores the interrupt; the WARN names the consumer and the blocking frame, the stop stays synchronous and returns once the call returns; no such WARN when the timeout waits for an inflight exchange. Fails without the change (5 of 6). - `JmsConsumerListenerContainerStopTimeoutTest` (embedded Artemis, 11 tests; 7 fail on main): suspend/destroy that does not return, resume/start after a timeout, interrupt, `autoStartup=false`, errors in the background, healthy suspend/resume/stop, suspend from the listener thread (Default, Simple, Simple + `SyncTaskExecutor`). - `SpringRabbitMQConsumerStopTest` (real Spring containers over a mocked channel whose `basicCancel` blocks and ignores interrupts; DMLC + SMLC, 20 runs: 14 of the first 16 fail on main; the other 4 cover an `Error` thrown by the stop, in time and in the background) and `RabbitMQConsumerSuspendResumeIT` (real broker: 0 consumers while suspended, message kept and consumed after resume). - Full suites: camel-core (9877 tests), camel-jms unit tests (562), camel-spring-rabbitmq unit tests + ITs. ## Known limitations (not changed here) - camel-activemq6 with `useSingleConnection=true`: `ActiveMQComponent.doStop()` resets the `SingleConnectionFactory`, which waits for the same connection lock as the blocked `Connection.stop()`. - camel-spring-rabbitmq: when the broker still delivers on one channel of the detached container but does not answer the cancel on another, those deliveries still reach the route (as they did while the suspend blocked). - camel-jms: a `temp-queue`/`temp-topic` consumer whose container is replaced uses the cached temporary destination of the old connection; the JMS producer's reply-manager containers are not covered; with a listener count still positive when the CamelContext stops, `JmsEndpoint` skips its stop (as with `asyncStopListener=true` today). - If the component's thread pool rejects the task (component already stopped), the container is stopped inline, as before. - camel-core: a shutdown task cancelled at the timeout can still go on to the next route's suspend before it checks the timeout (pre-existing, see CAMEL-26555). _Claude Code on behalf of Croway_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
