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 2023/12/07 10:09:39 UTC

(camel) 01/15: CAMEL-20189: camel-ftp: Force marking the consumer ready sooner, in case downloading a big file takes too long, causing readiness check to timeout and fail.

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

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

commit 6cd5face0ffe43b89e94f918f7f25c138ecd4fdd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 7 09:47:37 2023 +0100

    CAMEL-20189: camel-ftp: Force marking the consumer ready sooner, in case downloading a big file takes too long, causing readiness check to timeout and fail.
---
 .../component/file/remote/RemoteFileConsumer.java      |  3 +++
 .../apache/camel/support/ScheduledPollConsumer.java    | 18 +++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
index 82ff2fff563..bc50429d546 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
@@ -94,6 +94,9 @@ public abstract class RemoteFileConsumer<T> extends GenericFileConsumer<T> {
             loggedInWarning = false;
         }
 
+        // we are logged in so lets mark the consumer as ready
+        forceConsumerAsReady();
+
         return true;
     }
 
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 86337c9979c..960680b6a0f 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
@@ -480,7 +480,11 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
     }
 
     /**
-     * Whether a first pool attempt has been done (also if the consumer has been restarted)
+     * Whether a first pool attempt has been done (also if the consumer has been restarted).
+     *
+     * The health-check is using this information to know when the consumer is ready for readiness checks.
+     *
+     * @see #forceFirstPollDone()
      */
     public boolean isFirstPollDone() {
         return firstPollDone;
@@ -489,6 +493,18 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
     // Implementation methods
     // -------------------------------------------------------------------------
 
+    /**
+     * Forces the consumer to be marked as ready. This can be used by components that
+     * need to mark this sooner than usual (default marked as ready after first poll is done).
+     * This allows health-checks to be ready before an entire poll is completed.
+     *
+     * This is for example needed by the FTP component as polling a large file can take long time,
+     * causing a health-check to not be ready within reasonable time.
+     */
+    protected void forceConsumerAsReady() {
+        firstPollDone = true;
+    }
+
     /**
      * Gets the last caused error (exception) for the last poll that failed. When the consumer is successfully again,
      * then the error resets to null.