allthingssecurity opened a new pull request, #28261: URL: https://github.com/apache/camel/pull/28261
# Description [CAMEL-25840](https://issues.apache.org/jira/browse/CAMEL-25840) `HazelcastSedaConsumer.doStop` shut its executor down without waiting and then stopped the processor, while its threads usually still waited in `queue.poll(pollTimeout)` (1 s by default). A poll takes the item from the queue: an item offered in that window was taken by the stopping consumer, its exchange failed with `RouteStoppingException`, and without `transacted` (the default) the item was lost, with one WARN. On a busy queue this happens at nearly every stop of the route (stop, restart, failover, shutdown), up to one item per consumer thread. Changes (`HazelcastSedaConsumer.doStop`): - Wait for the consumer threads to end their current poll and route what it returned (graceful executor shutdown, bounded by `shutdownAwaitTermination`), then stop the processor. - Shut down the error-delay scheduler after the threads, since they use it: a thread in the delay after a failed poll waits (`BackgroundTask.run`, a latch) for a task of that scheduler, and shutting the scheduler down cancels that task. On main the scheduler was shut down first, so such a thread was left waiting for ever; with the graceful wait it would also hold the stop until the 10 s timeout. A stop takes at most `pollTimeout` longer. No option changed, so no upgrade guide entry. Only `doStop` is touched; it merges cleanly with the change of CAMEL-25816 to the loop of the same class. Tests: - New `HazelcastSedaConsumerStopTest` (2 tests; an embedded Hazelcast member, and a mocked instance for the failing queue): `itemOfferedAfterTheRouteStoppedStaysInTheQueue` stops the idle route while it polls, then offer an item. Without the change the item is taken from the queue (`expected: <1> but was: <0>`); with the change it stays and the next start routes it. - `threadInTheDelayAfterAFailedPollEndsWhenTheRouteStops` (same class): a route on a queue whose every poll fails (`onErrorDelay=3000`) is stopped while its thread waits in the error delay; the stop takes less than 8 s and the thread ends. Without the change the thread is left (`A consumer thread is left: [... hazelcast-seda://failing ...]`). - camel-hazelcast unit tests with the change: 244 run, 0 failures, 1 error (`HazelcastUserConfigSerializationFilterWarningTest.warnsForUserClientConfigWithoutFilter`: a client that cannot reach a cluster here; it errors the same way without the change). How it was found: variant analysis of CAMEL-25790 (a consumer with its own loops, and what its stop does to them), next to CAMEL-25837, then the JUnit test. What was not run: a Hazelcast client (only an embedded member); the full root build. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-25840](https://issues.apache.org/jira/browse/CAMEL-25840). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested camel-hazelcast. No option and no component page changed. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
