allthingssecurity opened a new pull request, #27992: URL: https://github.com/apache/camel/pull/27992
# Description [CAMEL-25712](https://issues.apache.org/jira/browse/CAMEL-25712) With `synchronousPull=true`, `GooglePubsubConsumer` pulls in a loop on its own thread. Since CAMEL-23142 a message whose delivery attempt reached `maxDeliveryAttempts` (the endpoint option, or the dead-letter policy of the subscription read at start) is nacked without routing. `AcknowledgeSync.nack` wraps a failure of that `ModifyAckDeadline` call in a `RuntimeCamelException`, and the `try` of the pull loop only catches `CancellationException`, `IOException` and `ExecutionException`. So one failed nack (`UNAVAILABLE` for longer than the client retries, which by default retry `ModifyAckDeadline` only on `UNAVAILABLE` within 60 s; any other status such as `DEADLINE_EXCEEDED`, which is not retried; an expired ack id with exactly-once delivery) ended the consumer thread: `run()` logged "Failure getting messages from PubSub" and returned. The route stayed started and nothing was pulled again until a restart. Change (`GooglePubsubConsumer` only): the nack of a message at the limit is wrapped in a `try`. A failure goes to the consumer's `ExceptionHandler` (WARN by default; the route's error handler with `bridgeErrorHandler=true`) and the loop goes on with the next message. The message is delivered again when its ack deadline expires and is nacked then, so a nack that keeps failing costs one WARN per redelivery, not a loop. Tests: - New `GooglePubsubConsumerNackFailureTest` (Mockito `SubscriberStub`, no emulator): the first pull returns a message at the limit whose nack fails with `UnavailableException`, the second pull a normal message, which must reach `mock:result` while the route is started. Bounded wait (10 s), no sleeps. - Without the change it fails: `mock://result Received message count. Expected: <1> but was: <0>`, with `RuntimeCamelException: ...UnavailableException` from `AcknowledgeSync.nack` in the log. - With the change the camel-google-pubsub tests pass: 17 run, 0 failures, 0 errors, 10 skipped (the skipped ones need the Pub/Sub emulator). What is not changed: - An `ExecutionException` of the pull whose cause is not retryable still ends the loop, on purpose (`synchronousPullRetryableCodes` widens the retryable codes), like the asynchronous subscriber. - The asynchronous subscriber path (its nack goes through the client's `AckReplyConsumer`). - No option or default changes, so no upgrade guide entry. What was not run: the integration tests with the Pub/Sub emulator and a real outage. # 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-25712](https://issues.apache.org/jira/browse/CAMEL-25712). # 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 camel-google-pubsub and the modules it depends on, including the formatter and import-sort plugins, and ran the camel-google-pubsub tests. 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]
