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 2024/07/03 13:45:10 UTC
(camel) branch main updated: Master retry (#14714)
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 573479b0045 Master retry (#14714)
573479b0045 is described below
commit 573479b004541ec0c8a5affbeddd4b34b8dae3f7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jul 3 15:45:04 2024 +0200
Master retry (#14714)
* CAMEL-15903: camel-master - Should retry starting consumer on leadership taken.
---
.../apache/camel/catalog/components/master.json | 6 +-
components/camel-jgroups-raft/pom.xml | 6 ++
.../raft/cluster/JGroupsRaftClusterView.java | 22 ++++++-
.../raft/cluster/JGroupsRaftMasterTest.java | 7 ++-
.../master/MasterComponentConfigurer.java | 12 ++++
.../org/apache/camel/component/master/master.json | 6 +-
.../camel/component/master/MasterComponent.java | 57 ++++++++++++++++++
.../camel/component/master/MasterConsumer.java | 70 +++++++++++++++-------
.../camel/component/master/MasterEndpoint.java | 9 ++-
.../dsl/MasterComponentBuilderFactory.java | 38 ++++++++++++
10 files changed, 203 insertions(+), 30 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/master.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/master.json
index 55dbb1f444e..5e55e0f7e63 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/master.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/master.json
@@ -25,8 +25,10 @@
"componentProperties": {
"bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...]
"autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
- "service": { "index": 2, "kind": "property", "displayName": "Service", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service to use." },
- "serviceSelector": { "index": 3, "kind": "property", "displayName": "Service Selector", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService.Selector", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service selector used to lookup the CamelClusterService to use." }
+ "backOffDelay": { "index": 2, "kind": "property", "displayName": "Back Off Delay", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "When the master becomes leader then backoff is in use to repeat starting the consumer until the consumer is successfully started or max attempts reached. This option is the delay in millis between start attempts." },
+ "backOffMaxAttempts": { "index": 3, "kind": "property", "displayName": "Back Off Max Attempts", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "When the master becomes leader then backoff is in use to repeat starting the consumer until the consumer is successfully started or max attempts reached. This option is the maximum number of attempts to try." },
+ "service": { "index": 4, "kind": "property", "displayName": "Service", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service to use." },
+ "serviceSelector": { "index": 5, "kind": "property", "displayName": "Service Selector", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService.Selector", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service selector used to lookup the CamelClusterService to use." }
},
"properties": {
"namespace": { "index": 0, "kind": "path", "displayName": "Namespace", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the cluster namespace to use" },
diff --git a/components/camel-jgroups-raft/pom.xml b/components/camel-jgroups-raft/pom.xml
index 497eb11bf00..429791057fc 100644
--- a/components/camel-jgroups-raft/pom.xml
+++ b/components/camel-jgroups-raft/pom.xml
@@ -67,6 +67,12 @@
<artifactId>camel-master</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>${awaitility-version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
diff --git a/components/camel-jgroups-raft/src/main/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftClusterView.java b/components/camel-jgroups-raft/src/main/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftClusterView.java
index 52e08b7a643..b983a10491a 100644
--- a/components/camel-jgroups-raft/src/main/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftClusterView.java
+++ b/components/camel-jgroups-raft/src/main/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftClusterView.java
@@ -82,8 +82,26 @@ public class JGroupsRaftClusterView extends AbstractCamelClusterView {
.raftId(raftId);
}
fireLeadershipChangedEvent((CamelClusterMember) null);
- raftHandle.addRoleListener(new ClusterRoleChangeListener(this));
- raftHandle.channel().connect(jgroupsClusterName);
+
+ // it may take a while for event to trigger and allow us to join so retry a while
+ Exception cause = null;
+ for (int i = 1; i < 11; i++) {
+ LOG.debug("Attempt #{} for raft {} to join {}", i, raftId, jgroupsClusterName);
+ try {
+ raftHandle.addRoleListener(new ClusterRoleChangeListener(this));
+ raftHandle.channel().connect(jgroupsClusterName);
+ LOG.debug("Joined and connected to {} with raft id: {}", jgroupsClusterName, raftId);
+ cause = null;
+ break;
+ } catch (Exception e) {
+ cause = e;
+ }
+ // wait for next attempt
+ Thread.sleep(5000);
+ }
+ if (cause != null) {
+ throw cause;
+ }
}
@Override
diff --git a/components/camel-jgroups-raft/src/test/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftMasterTest.java b/components/camel-jgroups-raft/src/test/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftMasterTest.java
index 984476313b6..e4badbaa393 100644
--- a/components/camel-jgroups-raft/src/test/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftMasterTest.java
+++ b/components/camel-jgroups-raft/src/test/java/org/apache/camel/component/jgroups/raft/cluster/JGroupsRaftMasterTest.java
@@ -25,6 +25,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jgroups.raft.utils.NopStateMachine;
import org.apache.camel.component.master.MasterConsumer;
import org.apache.camel.impl.DefaultCamelContext;
+import org.awaitility.Awaitility;
import org.jgroups.JChannel;
import org.jgroups.raft.RaftHandle;
import org.junit.jupiter.api.Test;
@@ -64,11 +65,11 @@ public class JGroupsRaftMasterTest extends JGroupsRaftClusterAbstractTest {
contextB.start();
contextC.start();
waitForLeader(50, handleA, handleB, handleC);
- assertEquals(1, countActiveFromEndpoints(lcc, rn));
+ Awaitility.await().untilAsserted(() -> assertEquals(1, countActiveFromEndpoints(lcc, rn)));
contextA.stop();
waitForLeader(50, handleA, handleB, handleC);
- assertEquals(1, countActiveFromEndpoints(lcc, rn));
+ Awaitility.await().untilAsserted(() -> assertEquals(1, countActiveFromEndpoints(lcc, rn)));
contextB.stop();
JGroupsRaftClusterService service = new JGroupsRaftClusterService();
@@ -79,7 +80,7 @@ public class JGroupsRaftMasterTest extends JGroupsRaftClusterAbstractTest {
contextA.addService(service);
contextA.start();
waitForLeader(50, handleA, handleB, handleC);
- assertEquals(1, countActiveFromEndpoints(lcc, rn));
+ Awaitility.await().untilAsserted(() -> assertEquals(1, countActiveFromEndpoints(lcc, rn)));
}
private CamelContext createContext(String id, RaftHandle rh) throws Exception {
diff --git a/components/camel-master/src/generated/java/org/apache/camel/component/master/MasterComponentConfigurer.java b/components/camel-master/src/generated/java/org/apache/camel/component/master/MasterComponentConfigurer.java
index fc783ff5d65..81a7ecfe5e7 100644
--- a/components/camel-master/src/generated/java/org/apache/camel/component/master/MasterComponentConfigurer.java
+++ b/components/camel-master/src/generated/java/org/apache/camel/component/master/MasterComponentConfigurer.java
@@ -25,6 +25,10 @@ public class MasterComponentConfigurer extends PropertyConfigurerSupport impleme
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
+ case "backoffdelay":
+ case "backOffDelay": target.setBackOffDelay(property(camelContext, long.class, value)); return true;
+ case "backoffmaxattempts":
+ case "backOffMaxAttempts": target.setBackOffMaxAttempts(property(camelContext, long.class, value)); return true;
case "bridgeerrorhandler":
case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true;
case "service": target.setService(property(camelContext, org.apache.camel.cluster.CamelClusterService.class, value)); return true;
@@ -39,6 +43,10 @@ public class MasterComponentConfigurer extends PropertyConfigurerSupport impleme
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": return boolean.class;
+ case "backoffdelay":
+ case "backOffDelay": return long.class;
+ case "backoffmaxattempts":
+ case "backOffMaxAttempts": return long.class;
case "bridgeerrorhandler":
case "bridgeErrorHandler": return boolean.class;
case "service": return org.apache.camel.cluster.CamelClusterService.class;
@@ -54,6 +62,10 @@ public class MasterComponentConfigurer extends PropertyConfigurerSupport impleme
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": return target.isAutowiredEnabled();
+ case "backoffdelay":
+ case "backOffDelay": return target.getBackOffDelay();
+ case "backoffmaxattempts":
+ case "backOffMaxAttempts": return target.getBackOffMaxAttempts();
case "bridgeerrorhandler":
case "bridgeErrorHandler": return target.isBridgeErrorHandler();
case "service": return target.getService();
diff --git a/components/camel-master/src/generated/resources/META-INF/org/apache/camel/component/master/master.json b/components/camel-master/src/generated/resources/META-INF/org/apache/camel/component/master/master.json
index 55dbb1f444e..5e55e0f7e63 100644
--- a/components/camel-master/src/generated/resources/META-INF/org/apache/camel/component/master/master.json
+++ b/components/camel-master/src/generated/resources/META-INF/org/apache/camel/component/master/master.json
@@ -25,8 +25,10 @@
"componentProperties": {
"bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...]
"autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
- "service": { "index": 2, "kind": "property", "displayName": "Service", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service to use." },
- "serviceSelector": { "index": 3, "kind": "property", "displayName": "Service Selector", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService.Selector", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service selector used to lookup the CamelClusterService to use." }
+ "backOffDelay": { "index": 2, "kind": "property", "displayName": "Back Off Delay", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "When the master becomes leader then backoff is in use to repeat starting the consumer until the consumer is successfully started or max attempts reached. This option is the delay in millis between start attempts." },
+ "backOffMaxAttempts": { "index": 3, "kind": "property", "displayName": "Back Off Max Attempts", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "When the master becomes leader then backoff is in use to repeat starting the consumer until the consumer is successfully started or max attempts reached. This option is the maximum number of attempts to try." },
+ "service": { "index": 4, "kind": "property", "displayName": "Service", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service to use." },
+ "serviceSelector": { "index": 5, "kind": "property", "displayName": "Service Selector", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.cluster.CamelClusterService.Selector", "deprecated": false, "autowired": false, "secret": false, "description": "Inject the service selector used to lookup the CamelClusterService to use." }
},
"properties": {
"namespace": { "index": 0, "kind": "path", "displayName": "Namespace", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the cluster namespace to use" },
diff --git a/components/camel-master/src/main/java/org/apache/camel/component/master/MasterComponent.java b/components/camel-master/src/main/java/org/apache/camel/component/master/MasterComponent.java
index 1e1e7e5b322..c986abde42e 100644
--- a/components/camel-master/src/main/java/org/apache/camel/component/master/MasterComponent.java
+++ b/components/camel-master/src/main/java/org/apache/camel/component/master/MasterComponent.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.master;
import java.util.Map;
+import java.util.concurrent.ScheduledExecutorService;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
@@ -37,10 +38,17 @@ import org.apache.camel.util.StringHelper;
*/
@Component("master")
public class MasterComponent extends DefaultComponent {
+
@Metadata(label = "advanced")
private CamelClusterService service;
@Metadata(label = "advanced")
private CamelClusterService.Selector serviceSelector;
+ @Metadata(label = "advanced")
+ private long backOffDelay = 5000;
+ @Metadata(label = "advanced")
+ private long backOffMaxAttempts = 10;
+
+ private ScheduledExecutorService backOffThreadPool;
public MasterComponent() {
this(null);
@@ -103,6 +111,38 @@ public class MasterComponent extends DefaultComponent {
this.serviceSelector = serviceSelector;
}
+ public ScheduledExecutorService getBackOffThreadPool() {
+ return backOffThreadPool;
+ }
+
+ public long getBackOffDelay() {
+ return backOffDelay;
+ }
+
+ /**
+ * When the master becomes leader then backoff is in use to repeat starting the consumer until the consumer is
+ * successfully started or max attempts reached.
+ *
+ * This option is the delay in millis between start attempts.
+ */
+ public void setBackOffDelay(long backOffDelay) {
+ this.backOffDelay = backOffDelay;
+ }
+
+ public long getBackOffMaxAttempts() {
+ return backOffMaxAttempts;
+ }
+
+ /**
+ * When the master becomes leader then backoff is in use to repeat starting the consumer until the consumer is
+ * successfully started or max attempts reached.
+ *
+ * This option is the maximum number of attempts to try.
+ */
+ public void setBackOffMaxAttempts(long backOffMaxAttempts) {
+ this.backOffMaxAttempts = backOffMaxAttempts;
+ }
+
@Override
protected void doInit() throws Exception {
CamelContext context = getCamelContext();
@@ -114,4 +154,21 @@ public class MasterComponent extends DefaultComponent {
}
}
+ @Override
+ protected void doStart() throws Exception {
+ if (backOffThreadPool == null) {
+ backOffThreadPool
+ = getCamelContext().getExecutorServiceManager().newDefaultScheduledThreadPool(this, "MasterLeaderTask");
+ }
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ super.doStop();
+
+ if (backOffThreadPool == null) {
+ getCamelContext().getExecutorServiceManager().shutdown(backOffThreadPool);
+ backOffThreadPool = null;
+ }
+ }
}
diff --git a/components/camel-master/src/main/java/org/apache/camel/component/master/MasterConsumer.java b/components/camel-master/src/main/java/org/apache/camel/component/master/MasterConsumer.java
index 2204e82e322..61b2a763001 100644
--- a/components/camel-master/src/main/java/org/apache/camel/component/master/MasterConsumer.java
+++ b/components/camel-master/src/main/java/org/apache/camel/component/master/MasterConsumer.java
@@ -33,6 +33,8 @@ import org.apache.camel.resume.ResumeStrategy;
import org.apache.camel.support.DefaultConsumer;
import org.apache.camel.support.resume.AdapterHelper;
import org.apache.camel.support.service.ServiceHelper;
+import org.apache.camel.util.backoff.BackOff;
+import org.apache.camel.util.backoff.BackOffTimer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +43,7 @@ import org.slf4j.LoggerFactory;
*/
@ManagedResource(description = "Managed Master Consumer")
public class MasterConsumer extends DefaultConsumer implements ResumeAware<ResumeStrategy> {
- private static final transient Logger LOG = LoggerFactory.getLogger(MasterConsumer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MasterConsumer.class);
private final CamelClusterService clusterService;
private final MasterEndpoint masterEndpoint;
@@ -133,31 +135,59 @@ public class MasterConsumer extends DefaultConsumer implements ResumeAware<Resum
return;
}
- delegatedConsumer = delegatedEndpoint.createConsumer(processor);
- if (delegatedConsumer instanceof StartupListener) {
- getEndpoint().getCamelContext().addStartupListener((StartupListener) delegatedConsumer);
- }
-
- if (delegatedConsumer instanceof ResumeAware resumeAwareConsumer && resumeStrategy != null) {
- LOG.info("Setting up the resume adapter for the resume strategy in the delegated consumer");
- ResumeAdapter resumeAdapter
- = AdapterHelper.eval(clusterService.getCamelContext(), resumeAwareConsumer, resumeStrategy);
- resumeStrategy.setAdapter(resumeAdapter);
+ // start consumer using background task up till X attempts
+ long delay = masterEndpoint.getComponent().getBackOffDelay();
+ long max = masterEndpoint.getComponent().getBackOffMaxAttempts();
+
+ BackOffTimer timer = new BackOffTimer(masterEndpoint.getComponent().getBackOffThreadPool());
+ timer.schedule(BackOff.builder().delay(delay).maxAttempts(max).build(), task -> {
+ LOG.info("Leadership taken. Attempt #{} to start consumer: {}", task.getCurrentAttempts(),
+ delegatedEndpoint);
+
+ Exception cause = null;
+ try {
+ if (delegatedConsumer == null) {
+ delegatedConsumer = delegatedEndpoint.createConsumer(processor);
+ if (delegatedConsumer instanceof StartupListener) {
+ getEndpoint().getCamelContext().addStartupListener((StartupListener) delegatedConsumer);
+ }
+ if (delegatedConsumer instanceof ResumeAware resumeAwareConsumer && resumeStrategy != null) {
+ LOG.debug("Setting up the resume adapter for the resume strategy in consumer");
+ ResumeAdapter resumeAdapter
+ = AdapterHelper.eval(clusterService.getCamelContext(), resumeAwareConsumer,
+ resumeStrategy);
+ resumeStrategy.setAdapter(resumeAdapter);
+
+ LOG.debug("Setting up the resume strategy for consumer");
+ resumeAwareConsumer.setResumeStrategy(resumeStrategy);
+ }
+ }
+ ServiceHelper.startService(delegatedEndpoint, delegatedConsumer);
- LOG.info("Setting up the resume strategy for the delegated consumer");
- resumeAwareConsumer.setResumeStrategy(resumeStrategy);
- }
+ } catch (Exception e) {
+ cause = e;
+ }
- ServiceHelper.startService(delegatedEndpoint, delegatedConsumer);
+ if (cause != null) {
+ String message = "Leadership taken. Attempt #" + task.getCurrentAttempts()
+ + " failed to start consumer due to: " + cause.getMessage();
+ getExceptionHandler().handleException(message, cause);
+ return true; // retry
+ }
- LOG.info("Leadership taken. Consumer started: {}", delegatedEndpoint);
+ LOG.info("Leadership taken. Attempt #" + task.getCurrentAttempts() + " success. Consumer started: {}",
+ delegatedEndpoint);
+ return false; // no more attempts
+ });
}
private synchronized void onLeadershipLost() {
- ServiceHelper.stopAndShutdownServices(delegatedConsumer, delegatedEndpoint);
-
- delegatedConsumer = null;
-
+ LOG.debug("Leadership lost. Stopping consumer: {}", delegatedEndpoint);
+ try {
+ ServiceHelper.stopAndShutdownServices(delegatedConsumer, delegatedEndpoint);
+ } finally {
+ delegatedConsumer = null;
+ }
LOG.info("Leadership lost. Consumer stopped: {}", delegatedEndpoint);
}
diff --git a/components/camel-master/src/main/java/org/apache/camel/component/master/MasterEndpoint.java b/components/camel-master/src/main/java/org/apache/camel/component/master/MasterEndpoint.java
index 428632779bf..ff52293fe4b 100644
--- a/components/camel-master/src/main/java/org/apache/camel/component/master/MasterEndpoint.java
+++ b/components/camel-master/src/main/java/org/apache/camel/component/master/MasterEndpoint.java
@@ -63,6 +63,11 @@ public class MasterEndpoint extends DefaultEndpoint implements DelegateEndpoint
this.delegateEndpoint = getCamelContext().getEndpoint(delegateUri);
}
+ @Override
+ public MasterComponent getComponent() {
+ return (MasterComponent) super.getComponent();
+ }
+
@Override
public Producer createProducer() throws Exception {
throw new UnsupportedOperationException("Cannot produce from this endpoint");
@@ -70,7 +75,9 @@ public class MasterEndpoint extends DefaultEndpoint implements DelegateEndpoint
@Override
public Consumer createConsumer(Processor processor) throws Exception {
- return new MasterConsumer(this, processor, clusterService);
+ MasterConsumer consumer = new MasterConsumer(this, processor, clusterService);
+ configureConsumer(consumer);
+ return consumer;
}
@Override
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MasterComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MasterComponentBuilderFactory.java
index 64468745eb2..7d202c99539 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MasterComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MasterComponentBuilderFactory.java
@@ -102,6 +102,42 @@ public interface MasterComponentBuilderFactory {
return this;
}
+ /**
+ * When the master becomes leader then backoff is in use to repeat
+ * starting the consumer until the consumer is successfully started or
+ * max attempts reached. This option is the delay in millis between
+ * start attempts.
+ *
+ * The option is a: <code>long</code> type.
+ *
+ * Group: advanced
+ *
+ * @param backOffDelay the value to set
+ * @return the dsl builder
+ */
+ default MasterComponentBuilder backOffDelay(long backOffDelay) {
+ doSetProperty("backOffDelay", backOffDelay);
+ return this;
+ }
+
+ /**
+ * When the master becomes leader then backoff is in use to repeat
+ * starting the consumer until the consumer is successfully started or
+ * max attempts reached. This option is the maximum number of attempts
+ * to try.
+ *
+ * The option is a: <code>long</code> type.
+ *
+ * Group: advanced
+ *
+ * @param backOffMaxAttempts the value to set
+ * @return the dsl builder
+ */
+ default MasterComponentBuilder backOffMaxAttempts(long backOffMaxAttempts) {
+ doSetProperty("backOffMaxAttempts", backOffMaxAttempts);
+ return this;
+ }
+
/**
* Inject the service to use.
*
@@ -152,6 +188,8 @@ public interface MasterComponentBuilderFactory {
switch (name) {
case "bridgeErrorHandler": ((MasterComponent) component).setBridgeErrorHandler((boolean) value); return true;
case "autowiredEnabled": ((MasterComponent) component).setAutowiredEnabled((boolean) value); return true;
+ case "backOffDelay": ((MasterComponent) component).setBackOffDelay((long) value); return true;
+ case "backOffMaxAttempts": ((MasterComponent) component).setBackOffMaxAttempts((long) value); return true;
case "service": ((MasterComponent) component).setService((org.apache.camel.cluster.CamelClusterService) value); return true;
case "serviceSelector": ((MasterComponent) component).setServiceSelector((org.apache.camel.cluster.CamelClusterService.Selector) value); return true;
default: return false;