allthingssecurity opened a new pull request, #29996:
URL: https://github.com/apache/camel/pull/29996

   # Description
   
   [CAMEL-26955](https://issues.apache.org/jira/browse/CAMEL-26955), part of 
CAMEL-26610. The world drives the consumer with `synchronousPull=true` (the 
default is the asynchronous subscriber, whose leases and redelivery are inside 
the client library, which the world does not run). One difference from the JIRA 
text: ack deadline extensions are not driven, as the synchronous pull consumer 
does not extend a deadline.
   
   Adds its row to the generated DST worlds table next to the Kafka world PR; 
whichever merges second will be rebased and the table regenerated.
   
   A deterministic simulation test (camel-test-dst) of the camel-google-pubsub 
consumer with `synchronousPull=true`, in the `dst` package of its tests, in the 
same form as the SQS world: `PubsubConsumerDstTest` (1000 seeds), `PubsubWorld` 
and `FakePubsub`. Test only; no main code changes.
   
   What the world models: the real consumer (`GooglePubsubConsumer`, its pull 
loop and `AcknowledgeSync`) and Camel's routing run on the virtual-time loop; 
only the subscription is faked, behind the `SubscriberStub` that the component 
hands out (a component subclass in the test overrides `getSubscriberStub`). The 
fake is written from the Pub/Sub documentation of Pull, Acknowledge and 
ModifyAckDeadline and cites it: a pull waits for messages and returns up to 
`maxMessages`, an ack deadline that expires delivers the message again, a nack 
is a deadline of zero, and the dead letter policy of the subscription counts 
the delivery attempts and dead-letters a message after the last one. The future 
of a pull is the harness's own, so a cancelled pull answers at once.
   
   The seed picks the ack mode (AUTO, or NONE with the route grouping the 
messages with `GroupedExchangeAggregationStrategy` and acking or nacking the 
group with the acknowledge header), the ack deadline, `maxMessagesPerPoll`, 
`maxDeliveryAttempts` and the fault rates, and injects failed pulls, acks and 
nacks, slow answers, failed processing (in some seeds most of it) and 
processing slower than the ack deadline, route restarts while the consumer 
pulls, and, with AUTO, a stop and start of the same consumer in one step, as a 
throttling route policy does.
   
   Invariants: a delivery is acked only after its exchange completed, and 
nacked only after it failed, reached `maxDeliveryAttempts` or was rejected by 
the stopped route (a pull that answers while the route stops); a delivery at 
`maxDeliveryAttempts` is nacked without routing it; a manual ack of a group 
acks every message of the group; a stopped consumer issues no pull, and the 
consumer has one pull at a time; once the faults cleared every message is acked 
or dead lettered, and a message published then is routed and acked (so a 
consumer whose pull loop ended is seen); the consumer uses the subscription as 
documented.
   
   Limits, written in the world's Javadoc: `concurrentConsumers` is 1 (a pull 
loop runs for ever, and on the one stack of the harness a second loop nested 
above the first would never let it resume); the operator stops the route only 
while no exchange is in it; the stop and start of the same consumer is done 
only with AUTO, as with grouped messages the loop of the new start could run 
nested above the processing of a group; a pull between the stop of the pulls by 
`deferShutdown` and the stop of the consumer cannot be reached on the one 
stack. Not explored: the asynchronous subscriber, `concurrentConsumers` above 
1, message ordering, exactly-once delivery.
   
   Other changes:
   - `camel-test-dst` as a test dependency of camel-google-pubsub, and its byte 
code agent on the surefire command line, as for the other worlds.
   - The test log of camel-google-pubsub goes to a size-capped rolling file (50 
MB, one backup), as a failing world can log a lot.
   - The `@DstWorld` annotation lists the world in the component JSON (and its 
catalog copy) and in the table of the camel-test-dst page (and its catalog 
copy, byte-identical).
   
   Tests:
   - On main: 5000 of 5000 seeds pass (about 8 ms a seed). Seeds 8 and 77 
replayed in two JVMs give the same trace hashes.
   - Self-check against fixed bugs, each reverted on main: before CAMEL-26647 
(6ebc180cfec4) 606 of 2000 seeds fail (the manual ack of a group); before 
CAMEL-25790 (c2962f91b523) 664 of 2000 fail (two pulls at a time after the 
consumer was started again); before CAMEL-25712 (f245636df70f) 8 of 2000 fail 
(the pull loop ended after a failed nack at the max delivery attempts, and the 
message published at the end is not routed). The last one needs a message at 
its last delivery attempt and a failed nack of it after the last restart, so 
few seeds reach it.
   - camel-google-pubsub unit tests: 1038 run (38, plus 1000 seeds), 0 
failures, 0 errors, 10 skipped (skipped before this change too).
   
   What was not run locally: the ITs (they need Docker) and the full root 
build. I built and tested offline with the versions cached on my machine: 
google-cloud-pubsub 1.157.0 and gRPC 1.84.2 (main has 1.160.0 and 1.85.1), 
commons-lang3 3.21.0 and Guava 33.7.2 (main has 3.22.0 and 33.8.0-jre).
   
   # 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-26955](https://issues.apache.org/jira/browse/CAMEL-26955).
   
   # 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-test-dst, camel-google-common and 
camel-google-pubsub, including the formatter and import-sort plugins. The 
generated files touched are the component JSON with its catalog copy, and the 
table of the camel-test-dst page with its catalog copy (byte-identical). 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]

Reply via email to