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

orpiske 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 4df86fac3f2 CAMEL-18125 fix multi node Kafka resume strategy empty 
cache
4df86fac3f2 is described below

commit 4df86fac3f289bf07ef4908c2b1d1edb11d82224
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Jun 21 13:57:04 2022 +0200

    CAMEL-18125 fix multi node Kafka resume strategy empty cache
    
    In multi-node setups (clustering), loading the cache should also be delayed 
until the component is starting
---
 .../processor/resume/kafka/MultiNodeKafkaResumeStrategy.java  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-kafka/src/main/java/org/apache/camel/processor/resume/kafka/MultiNodeKafkaResumeStrategy.java
 
b/components/camel-kafka/src/main/java/org/apache/camel/processor/resume/kafka/MultiNodeKafkaResumeStrategy.java
index c887a21b84b..4cfe256fb3d 100644
--- 
a/components/camel-kafka/src/main/java/org/apache/camel/processor/resume/kafka/MultiNodeKafkaResumeStrategy.java
+++ 
b/components/camel-kafka/src/main/java/org/apache/camel/processor/resume/kafka/MultiNodeKafkaResumeStrategy.java
@@ -66,9 +66,7 @@ public class MultiNodeKafkaResumeStrategy<K extends 
Resumable> extends SingleNod
                                         ExecutorService executorService) {
         super(resumeStrategyConfiguration);
 
-        // We need to keep refreshing the cache
         this.executorService = executorService;
-        executorService.submit(() -> refresh());
     }
 
     protected void poll() {
@@ -96,10 +94,17 @@ public class MultiNodeKafkaResumeStrategy<K extends 
Resumable> extends SingleNod
         } while (true);
     }
 
+    @Override
+    public void loadCache() throws Exception {
+        super.loadCache();
+
+        executorService.submit(() -> refresh());
+    }
+
     /**
      * Launch a thread to refresh the offsets periodically
      */
-    protected void refresh() {
+    private void refresh() {
         LOG.trace("Creating a offset cache refresher");
         try {
             Properties prop = (Properties) 
getResumeStrategyConfiguration().getConsumerProperties().clone();

Reply via email to