allthingssecurity commented on code in PR #28139:
URL: https://github.com/apache/camel/pull/28139#discussion_r4323020333


##########
components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/dst/SqsWorld.java:
##########
@@ -112,9 +112,20 @@ public void configure() {
             // faults cleared: the queue must drain
             faults = false;
             sqs.faults = false;
-            long deadline = dst.now() + 20L * visibilityTimeout * 1000 + 
30_000;
-            while (!sqs.allDeleted() && dst.now() < deadline) {
+            // drain while it makes progress: stop when no message was deleted 
for a while, or at a cap. A fixed
+            // drain time failed falsely when the consumer was still deleting 
messages at its end (one consumer
+            // taking one message per poll with a 1 s delay, and short polling 
returning fewer messages than asked)
+            long quiet = 20L * visibilityTimeout * 1000 + 30_000;
+            long cap = dst.now() + 3_600_000;
+            int left = sqs.notDeleted().size();
+            long lastProgress = dst.now();
+            while (!sqs.allDeleted() && dst.now() < cap && dst.now() - 
lastProgress < quiet) {
                 dst.runFor(100);
+                int now = sqs.notDeleted().size();
+                if (now < left) {
+                    left = now;

Review Comment:
   Renamed to `remaining` in dbbd4e088398. SqsVisibilityDstTest: 1000 seeds, 0 
failures.
   
   _Claude Code on behalf of allthingssecurity_



-- 
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