You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/02/01 17:41:04 UTC

[camel] branch main updated: CAMEL-17577: setting firstPollDone to true if greedy polling is enabled (#6865)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 093044d  CAMEL-17577: setting firstPollDone to true if greedy polling is enabled (#6865)
093044d is described below

commit 093044d6b3af552922fb50710673ec2bcfb7f328
Author: Benjamin Graf <gr...@users.noreply.github.com>
AuthorDate: Tue Feb 1 18:40:19 2022 +0100

    CAMEL-17577: setting firstPollDone to true if greedy polling is enabled (#6865)
---
 .../org/apache/camel/support/ScheduledPollConsumer.java     | 13 ++++++++-----
 .../camel/support/ScheduledPollConsumerHealthCheck.java     |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
index 0cf8c9b..4c6680a 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
@@ -78,7 +78,7 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
     private volatile Throwable lastError;
     private volatile Map<String, Object> lastErrorDetails;
     private final AtomicLong counter = new AtomicLong();
-    private volatile boolean firstPoolDone;
+    private volatile boolean firstPollDone;
 
     public ScheduledPollConsumer(Endpoint endpoint, Processor processor) {
         super(endpoint, processor);
@@ -213,6 +213,9 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
                                 done = false;
                                 retryCounter = -1;
                                 LOG.trace("Greedy polling after processing {} messages", polledMessages);
+
+                                // setting firstPollDone to true if greedy polling is enabled
+                                firstPollDone = true;
                             }
                         } else {
                             LOG.debug("Cannot begin polling as pollStrategy returned false: {}", pollStrategy);
@@ -276,7 +279,7 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
         }
 
         // now first pool is done after the poll is complete
-        firstPoolDone = true;
+        firstPollDone = true;
 
         LOG.trace("doRun() done with idleCounter={}, successCounter={}, errorCounter={}", idleCounter, successCounter,
                 errorCounter);
@@ -478,8 +481,8 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
     /**
      * Whether a first pool attempt has been done (also if the consumer has been restarted)
      */
-    protected boolean isFirstPoolDone() {
-        return firstPoolDone;
+    protected boolean isFirstPollDone() {
+        return firstPollDone;
     }
 
     /**
@@ -640,7 +643,7 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
         errorCounter = 0;
         successCounter = 0;
         counter.set(0);
-        firstPoolDone = false;
+        firstPollDone = false;
 
         super.doStop();
     }
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java
index fbd49da..3fff81f 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java
@@ -55,7 +55,7 @@ public class ScheduledPollConsumerHealthCheck implements HealthCheck {
         builder.detail(FAILURE_ENDPOINT_URI, sanitizedUri);
 
         long ec = consumer.getErrorCounter();
-        boolean first = consumer.isFirstPoolDone();
+        boolean first = consumer.isFirstPollDone();
         Throwable cause = consumer.getLastError();
 
         // can only be healthy if we have at least one poll done and there are no errors