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 23bc08638361 CAMEL-27901: camel-salesforce: send Bulk API PK chunking
options as a single header value (#31168)
23bc08638361 is described below
commit 23bc08638361d493b0b91846d1e877f82dfdd6cf
Author: James Netherton <[email protected]>
AuthorDate: Tue Dec 1 12:35:31 2026 +0000
CAMEL-27901: camel-salesforce: send Bulk API PK chunking options as a
single header value (#31168)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../camel/catalog/docs/salesforce-bulk-api.adoc | 2 +-
.../src/main/docs/salesforce-bulk-api.adoc | 2 +-
.../internal/processor/BulkApiProcessor.java | 13 ++--
.../component/salesforce/BulkApiQueryManualIT.java | 13 ++++
.../internal/processor/BulkApiProcessorTest.java | 82 ++++++++++++++++++++++
5 files changed, 104 insertions(+), 8 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/salesforce-bulk-api.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/salesforce-bulk-api.adoc
index 7fffff016e2f..1e51f86cec8b 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/salesforce-bulk-api.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/salesforce-bulk-api.adoc
@@ -350,7 +350,7 @@ is supported via the pkChunking* options. See an
explanation https://developer.s
| Body | `JobInfo` | Job to create | | x
| `pkChunking` | `Boolean` | Whether to use PK Chunking | false |
| `pkChunkingChunkSize` | `Integer` | | |
-| `pkChunkingStartRow` | `Integer` | | |
+| `pkChunkingStartRow` | `String` | | |
| `pkChunkingParent` | `String` | | |
|===
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-bulk-api.adoc
b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-bulk-api.adoc
index 7fffff016e2f..1e51f86cec8b 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-bulk-api.adoc
+++
b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-bulk-api.adoc
@@ -350,7 +350,7 @@ is supported via the pkChunking* options. See an
explanation https://developer.s
| Body | `JobInfo` | Job to create | | x
| `pkChunking` | `Boolean` | Whether to use PK Chunking | false |
| `pkChunkingChunkSize` | `Integer` | | |
-| `pkChunkingStartRow` | `Integer` | | |
+| `pkChunkingStartRow` | `String` | | |
| `pkChunkingParent` | `String` | | |
|===
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java
index 8e44584ebfdb..f2b016548957 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java
+++
b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java
@@ -137,27 +137,28 @@ public class BulkApiProcessor extends
AbstractSalesforceProcessor {
SalesforceEndpointConfig.PK_CHUNKING, exchange,
IGNORE_BODY, IS_OPTIONAL,
Boolean.class);
if (pkChunking != null && pkChunking) {
- List<String> values = new ArrayList<>();
- values.add("true");
+ // Salesforce expects a single value: TRUE, or the options
separated by semicolons
+ List<String> options = new ArrayList<>();
Integer chunkSize = getParameter(
SalesforceEndpointConfig.PK_CHUNKING_CHUNK_SIZE,
exchange, IGNORE_BODY, IS_OPTIONAL,
Integer.class);
if (chunkSize != null) {
- values.add("chunkSize=" + chunkSize);
+ options.add("chunkSize=" + chunkSize);
}
String startRow = getParameter(
SalesforceEndpointConfig.PK_CHUNKING_START_ROW,
exchange, IGNORE_BODY, IS_OPTIONAL,
String.class);
if (startRow != null) {
- values.add("startRow=" + startRow);
+ options.add("startRow=" + startRow);
}
String parent = getParameter(
SalesforceEndpointConfig.PK_CHUNKING_PARENT, exchange,
IGNORE_BODY, IS_OPTIONAL,
String.class);
if (parent != null) {
- values.add("parent=" + parent);
+ options.add("parent=" + parent);
}
- headers.put("Sforce-Enable-PKChunking", values);
+ headers.put("Sforce-Enable-PKChunking",
+ List.of(options.isEmpty() ? "TRUE" : String.join("; ",
options)));
}
} catch (SalesforceException e) {
throw new RuntimeException(e);
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/BulkApiQueryManualIT.java
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/BulkApiQueryManualIT.java
index 0f11e8327576..d27e28205b1c 100644
---
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/BulkApiQueryManualIT.java
+++
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/BulkApiQueryManualIT.java
@@ -124,4 +124,17 @@ public class BulkApiQueryManualIT extends
AbstractBulkApiTestBase {
// close the test job
template().requestBody("direct:closeJob", jobInfo, JobInfo.class);
}
+
+ @Test
+ public void testPkChunkingWithoutOptions() {
+ JobInfo jobInfo = new JobInfo();
+ jobInfo.setOperation(OperationEnum.QUERY);
+ jobInfo.setContentType(ContentType.CSV);
+ jobInfo.setObject(Merchandise__c.class.getSimpleName());
+ jobInfo = template().requestBodyAndHeader(
+ "direct:createJob", jobInfo,
SalesforceEndpointConfig.PK_CHUNKING, true, JobInfo.class);
+ assertNotNull(jobInfo.getId(), "Missing JobId");
+
+ template().requestBody("direct:closeJob", jobInfo, JobInfo.class);
+ }
}
diff --git
a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessorTest.java
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessorTest.java
new file mode 100644
index 000000000000..925812658151
--- /dev/null
+++
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessorTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.salesforce.internal.processor;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.salesforce.SalesforceComponent;
+import org.apache.camel.component.salesforce.SalesforceEndpoint;
+import org.apache.camel.component.salesforce.SalesforceEndpointConfig;
+import org.apache.camel.component.salesforce.internal.OperationName;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class BulkApiProcessorTest {
+
+ private static final String PK_CHUNKING_HEADER =
"Sforce-Enable-PKChunking";
+
+ @Test
+ public void pkChunkingWithoutOptions() throws Exception {
+ Map<String, List<String>> headers =
determineHeaders(Map.of(SalesforceEndpointConfig.PK_CHUNKING, true));
+
+ assertThat(headers).containsEntry(PK_CHUNKING_HEADER, List.of("TRUE"));
+ }
+
+ @Test
+ public void pkChunkingWithChunkSize() throws Exception {
+ Map<String, List<String>> headers = determineHeaders(Map.of(
+ SalesforceEndpointConfig.PK_CHUNKING, true,
+ SalesforceEndpointConfig.PK_CHUNKING_CHUNK_SIZE, 1000));
+
+ assertThat(headers).containsEntry(PK_CHUNKING_HEADER,
List.of("chunkSize=1000"));
+ }
+
+ @Test
+ public void pkChunkingWithAllOptions() throws Exception {
+ Map<String, List<String>> headers = determineHeaders(Map.of(
+ SalesforceEndpointConfig.PK_CHUNKING, true,
+ SalesforceEndpointConfig.PK_CHUNKING_CHUNK_SIZE, 1000,
+ SalesforceEndpointConfig.PK_CHUNKING_START_ROW,
"00130000000xEftMGH",
+ SalesforceEndpointConfig.PK_CHUNKING_PARENT, "Account"));
+
+ assertThat(headers).containsEntry(PK_CHUNKING_HEADER,
+ List.of("chunkSize=1000; startRow=00130000000xEftMGH;
parent=Account"));
+ }
+
+ @Test
+ public void noPkChunking() throws Exception {
+ Map<String, List<String>> headers =
determineHeaders(Map.of(SalesforceEndpointConfig.PK_CHUNKING, false));
+
+ assertThat(headers).doesNotContainKey(PK_CHUNKING_HEADER);
+ }
+
+ private static Map<String, List<String>> determineHeaders(Map<String,
Object> messageHeaders) throws Exception {
+ SalesforceEndpoint endpoint = new SalesforceEndpoint(
+ "", new SalesforceComponent(), new SalesforceEndpointConfig(),
OperationName.CREATE_JOB, "");
+ try (DefaultCamelContext context = new DefaultCamelContext();
+ BulkApiProcessor processor = new BulkApiProcessor(endpoint)) {
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setHeaders(messageHeaders);
+ return processor.determineHeaders(exchange);
+ }
+ }
+}