allthingssecurity opened a new pull request, #30357: URL: https://github.com/apache/camel/pull/30357
# Description [CAMEL-27166](https://issues.apache.org/jira/browse/CAMEL-27166) With `synchronousPull=true` and the default `ackMode`, the consumer acks a completed exchange and nacks a failed one through `AcknowledgeSync`, which read the ack id from the `CamelGooglePubsubMsgAckId` header when the exchange was done. A route that removed the headers (for example `removeHeaders("*")` before calling another system), or replaced the message, acked nothing: a WARN was logged and Pub/Sub delivered the message again after its ack deadline, and again after every later delivery. A route that changed the header acked or nacked another ack id. The asynchronous subscriber was not affected, as it acks with the `AckReplyConsumer` of the message it received. This is the same defect that CAMEL-27015 (#30168) (aws2-sqs, aws2-s3, azure-storage-blob) and CAMEL-27064 (#30227) (google-storage, minio, alibaba-mns) fixed in other consumers. Fix: - `AcknowledgeSync` gets a constructor with the ack id of the message it acknowledges; such an instance acks or nacks that ack id, whatever the exchange given carries. The existing constructor keeps reading the ack ids from the exchange. - `GooglePubsubConsumer` creates the `AcknowledgeSync` of the automatic ack (and of the nack of a message that reached `maxDeliveryAttempts`) with the ack id of the received message. - Manual acknowledgement (`ackMode=NONE`) is unchanged: the `GooglePubsubAcknowledge` header still acks the ack ids of the exchange given, so that `ack` of an aggregated exchange acks every grouped message (CAMEL-26647). - The component page no longer says that a removed or changed header breaks the ack (that sentence came with CAMEL-26647 (#29332) and described what main did); the 4.24 upgrade guide has an entry, as the consumer now acks a message it did not ack before. Tests: `GooglePubsubSynchronousPullAckIdTest` runs the real consumer against a `SubscriberStub` that answers Pull with one message per call and records the Acknowledge and ModifyAckDeadline requests (the subclass the DST world `FakePubsub` also uses). Routes that remove the headers, change the ack id header, and remove the headers then fail: the received ack id must be acked (nacked for the failure), and two messages are each acked with their own ack id. Runs (offline, with the versions cached on my machine, google-cloud-pubsub 1.157.0): the four tests fail on main (no Acknowledge for the received ack id within 10 s, or the ack id of the changed header acked) and pass with the fix; camel-google-pubsub module tests 1050 run, 0 failures; the new test class 20 times in one JVM: 80 of 80. # 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-27166](https://issues.apache.org/jira/browse/CAMEL-27166). # 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 the core modules and camel-google-pubsub with the formatter and import-sort plugins, and copied the component page to the catalog. 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]
