This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.18.x by this push:
new e5e53c62f9f6 [backport camel-4.18.x] CAMEL-26646: camel-couchdb -
treat maxMessagesPerPoll <= 0 as unlimited (#29330)
e5e53c62f9f6 is described below
commit e5e53c62f9f69363ab2eb32a76b8649093bc76df
Author: Jiří Ondrušek <[email protected]>
AuthorDate: Fri Nov 6 17:10:22 2026 +0100
[backport camel-4.18.x] CAMEL-26646: camel-couchdb - treat
maxMessagesPerPoll <= 0 as unlimited (#29330)
* CAMEL-26646: camel-couchdb - treat maxMessagesPerPoll <= 0 as unlimited
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
---
.../apache/camel/catalog/components/couchdb.json | 2 +-
.../apache/camel/component/couchdb/couchdb.json | 2 +-
.../component/couchdb/CouchDbClientWrapper.java | 12 +++--
.../camel/component/couchdb/CouchDbEndpoint.java | 2 -
.../couchdb/CouchDbClientWrapperTest.java | 53 ++++++++++++++++++++++
.../dsl/CouchDbEndpointBuilderFactory.java | 10 ++--
6 files changed, 66 insertions(+), 15 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/couchdb.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/couchdb.json
index cf05f5234dff..66fdbfcf5c0c 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/couchdb.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/couchdb.json
@@ -44,7 +44,7 @@
"createDatabase": { "index": 4, "kind": "parameter", "displayName":
"Create Database", "group": "common", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Creates the database if
it does not already exist" },
"deletes": { "index": 5, "kind": "parameter", "displayName": "Deletes",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": true, "description": "Document deletes are published as
events" },
"heartbeat": { "index": 6, "kind": "parameter", "displayName":
"Heartbeat", "group": "consumer", "label": "consumer", "required": false,
"type": "duration", "javaType": "long", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "30000", "description": "How often to
send an empty message to keep socket alive in millis" },
- "maxMessagesPerPoll": { "index": 7, "kind": "parameter", "displayName":
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10, "description": "Gets the maximum
number of messages as a limit to poll at each polling. Gets the maximum number
of messages as a limit to poll at each polling. The default value is 10. Use 0
or a negative number to [...]
+ "maxMessagesPerPoll": { "index": 7, "kind": "parameter", "displayName":
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10, "description": "Gets the maximum
number of messages as a limit to poll at each polling. The default value is 10.
Use 0 or a negative number to set it as unlimited." },
"style": { "index": 8, "kind": "parameter", "displayName": "Style",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "all_docs", "main_only" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"main_only", "description": "Specifies how many revisions are returned in the
changes array. The default, main_only, will only return the current winning
revision; all_docs will return all leaf revisi [...]
"updates": { "index": 9, "kind": "parameter", "displayName": "Updates",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": true, "description": "Document inserts\/updates are
published as events" },
"bridgeErrorHandler": { "index": 10, "kind": "parameter", "displayName":
"Bridge Error Handler", "group": "consumer (advanced)", "label":
"consumer,advanced", "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 [...]
diff --git
a/components/camel-couchdb/src/generated/resources/META-INF/org/apache/camel/component/couchdb/couchdb.json
b/components/camel-couchdb/src/generated/resources/META-INF/org/apache/camel/component/couchdb/couchdb.json
index cf05f5234dff..66fdbfcf5c0c 100644
---
a/components/camel-couchdb/src/generated/resources/META-INF/org/apache/camel/component/couchdb/couchdb.json
+++
b/components/camel-couchdb/src/generated/resources/META-INF/org/apache/camel/component/couchdb/couchdb.json
@@ -44,7 +44,7 @@
"createDatabase": { "index": 4, "kind": "parameter", "displayName":
"Create Database", "group": "common", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Creates the database if
it does not already exist" },
"deletes": { "index": 5, "kind": "parameter", "displayName": "Deletes",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": true, "description": "Document deletes are published as
events" },
"heartbeat": { "index": 6, "kind": "parameter", "displayName":
"Heartbeat", "group": "consumer", "label": "consumer", "required": false,
"type": "duration", "javaType": "long", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": "30000", "description": "How often to
send an empty message to keep socket alive in millis" },
- "maxMessagesPerPoll": { "index": 7, "kind": "parameter", "displayName":
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10, "description": "Gets the maximum
number of messages as a limit to poll at each polling. Gets the maximum number
of messages as a limit to poll at each polling. The default value is 10. Use 0
or a negative number to [...]
+ "maxMessagesPerPoll": { "index": 7, "kind": "parameter", "displayName":
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10, "description": "Gets the maximum
number of messages as a limit to poll at each polling. The default value is 10.
Use 0 or a negative number to set it as unlimited." },
"style": { "index": 8, "kind": "parameter", "displayName": "Style",
"group": "consumer", "label": "consumer", "required": false, "type": "enum",
"javaType": "java.lang.String", "enum": [ "all_docs", "main_only" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"main_only", "description": "Specifies how many revisions are returned in the
changes array. The default, main_only, will only return the current winning
revision; all_docs will return all leaf revisi [...]
"updates": { "index": 9, "kind": "parameter", "displayName": "Updates",
"group": "consumer", "label": "consumer", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": true, "description": "Document inserts\/updates are
published as events" },
"bridgeErrorHandler": { "index": 10, "kind": "parameter", "displayName":
"Bridge Error Handler", "group": "consumer (advanced)", "label":
"consumer,advanced", "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 [...]
diff --git
a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
index e35f0fb1693d..37a0b13b6bec 100644
---
a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
+++
b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
@@ -90,13 +90,15 @@ public class CouchDbClientWrapper {
}
public Response<ChangesResult> pollChanges(String style, String since,
long heartBeat, long maxMessagesPerPoll) {
- PostChangesOptions postChangesOptions = new
PostChangesOptions.Builder()
+ PostChangesOptions.Builder builder = new PostChangesOptions.Builder()
.db(dbName)
- .since(since)
- .limit(maxMessagesPerPoll)
- .build();
+ .since(since);
+ // 0 or a negative number means unlimited: CouchDB has no such limit
value, so do not send one
+ if (maxMessagesPerPoll > 0) {
+ builder.limit(maxMessagesPerPoll);
+ }
- return client.postChanges(postChangesOptions).execute();
+ return client.postChanges(builder.build()).execute();
}
public Response get(String id) {
diff --git
a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbEndpoint.java
b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbEndpoint.java
index 3e20b7231698..5f3091a84440 100644
---
a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbEndpoint.java
+++
b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbEndpoint.java
@@ -272,8 +272,6 @@ public class CouchDbEndpoint extends DefaultEndpoint
implements EndpointServiceL
}
/**
- * Gets the maximum number of messages as a limit to poll at each polling.
- * <p/>
* Gets the maximum number of messages as a limit to poll at each polling.
The default value is 10. Use 0 or a
* negative number to set it as unlimited.
*/
diff --git
a/components/camel-couchdb/src/test/java/org/apache/camel/component/couchdb/CouchDbClientWrapperTest.java
b/components/camel-couchdb/src/test/java/org/apache/camel/component/couchdb/CouchDbClientWrapperTest.java
new file mode 100644
index 000000000000..f09c740d637e
--- /dev/null
+++
b/components/camel-couchdb/src/test/java/org/apache/camel/component/couchdb/CouchDbClientWrapperTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.couchdb;
+
+import com.ibm.cloud.cloudant.v1.Cloudant;
+import com.ibm.cloud.cloudant.v1.model.PostChangesOptions;
+import com.ibm.cloud.sdk.core.http.ServiceCall;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.mockito.ArgumentCaptor;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * maxMessagesPerPoll is sent as the limit of the _changes request, and 0 or a
negative number means no limit.
+ */
+public class CouchDbClientWrapperTest {
+
+ @ParameterizedTest
+ @CsvSource({ "10, 10", "1, 1", "0,", "-1,", "-5," })
+ @SuppressWarnings("unchecked")
+ void testPollChangesLimit(long maxMessagesPerPoll, Long expectedLimit) {
+ Cloudant cloudant = mock(Cloudant.class);
+ when(cloudant.postChanges(any())).thenReturn(mock(ServiceCall.class));
+ CouchDbClientWrapper wrapper = new CouchDbClientWrapper(cloudant,
"db", false);
+
+ wrapper.pollChanges("main_only", "now", 30000, maxMessagesPerPoll);
+
+ ArgumentCaptor<PostChangesOptions> options =
ArgumentCaptor.forClass(PostChangesOptions.class);
+ verify(cloudant).postChanges(options.capture());
+ assertEquals("db", options.getValue().db());
+ assertEquals("now", options.getValue().since());
+ assertEquals(expectedLimit, options.getValue().limit());
+ }
+}
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CouchDbEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CouchDbEndpointBuilderFactory.java
index 352dc4500100..f5ef26f5cc1a 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CouchDbEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CouchDbEndpointBuilderFactory.java
@@ -136,9 +136,8 @@ public interface CouchDbEndpointBuilderFactory {
}
/**
* Gets the maximum number of messages as a limit to poll at each
- * polling. Gets the maximum number of messages as a limit to poll at
- * each polling. The default value is 10. Use 0 or a negative number to
- * set it as unlimited.
+ * polling. The default value is 10. Use 0 or a negative number to set
+ * it as unlimited.
*
* The option is a: <code>int</code> type.
*
@@ -154,9 +153,8 @@ public interface CouchDbEndpointBuilderFactory {
}
/**
* Gets the maximum number of messages as a limit to poll at each
- * polling. Gets the maximum number of messages as a limit to poll at
- * each polling. The default value is 10. Use 0 or a negative number to
- * set it as unlimited.
+ * polling. The default value is 10. Use 0 or a negative number to set
+ * it as unlimited.
*
* The option will be converted to a <code>int</code> type.
*