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 7b6ffd97baed CAMEL-27167: camel-alibaba-oss, camel-huaweicloud-obs -
delete or move the consumed object (#30358)
7b6ffd97baed is described below
commit 7b6ffd97baed23cbf0dc5b7638afe9a8cbee7fb0
Author: allthingssecurity <[email protected]>
AuthorDate: Thu Nov 19 19:20:33 2026 +0530
CAMEL-27167: camel-alibaba-oss, camel-huaweicloud-obs - delete or move the
consumed object (#30358)
With deleteAfterRead (and moveAfterRead for OBS), the consumers took the
bucket and the key of the object to delete or move from the bucket and key
headers as the route left them. The producer writes to the bucket of the
bucket name header, so a route that set it to copy the object to another
bucket deleted the object with the same key in that bucket, and the consumed
object was consumed again; a route that removed the headers deleted nothing.
- OSSConsumer and OBSConsumer take the bucket and the key before the
exchange
is routed and delete (OBS: copy, then delete) that object when it
completes.
- alibaba-oss component page and 4.24 upgrade guide updated.
- OSSConsumerDeleteAfterReadTest and OBSConsumerMoveDeleteAfterReadTest:
a route that sets the headers, and a route that removes them.
For OBS the producer takes its bucket from the CamelHwCloudObsBucketName
exchange property, not from the header, so there a changed header copied and
deleted another object, and a removed header deleted nothing.
Related: CAMEL-27015 (#30168), CAMEL-27064 (#30227).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../camel/catalog/docs/alibaba-oss-component.adoc | 2 +
.../src/main/docs/alibaba-oss-component.adoc | 2 +
.../camel/component/alibaba/oss/OSSConsumer.java | 15 +-
.../oss/OSSConsumerDeleteAfterReadTest.java | 150 ++++++++++++++++++
.../component/huaweicloud/obs/OBSConsumer.java | 17 +-
.../obs/OBSConsumerMoveDeleteAfterReadTest.java | 173 +++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 14 ++
7 files changed, 363 insertions(+), 10 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-oss-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-oss-component.adoc
index 00e53ef6b3ce..bb8b45190f5d 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-oss-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-oss-component.adoc
@@ -81,6 +81,8 @@ If any of the above headers are set, they will override their
corresponding quer
=== Consumer
The consumer polls objects from a bucket using `listObjectsV2`, downloads each
object body, and optionally deletes objects after they have been processed when
`deleteAfterRead` is enabled.
+The consumer deletes the object it consumed, whatever the route does with the
`CamelAlibabaOssBucketName` and `CamelAlibabaOssObjectKey` headers.
+A route can set the bucket name header to write a copy of the object to
another bucket.
By default (`includeBody=true`) the consumer reads the content of each object
into a `byte[]`, which is the body, so an object needs as much memory as its
size.
With `includeBody=false` the body is the `InputStream` of the content of the
object instead, which the consumer closes when the exchange is done.
diff --git
a/components/camel-alibaba/camel-alibaba-oss/src/main/docs/alibaba-oss-component.adoc
b/components/camel-alibaba/camel-alibaba-oss/src/main/docs/alibaba-oss-component.adoc
index 00e53ef6b3ce..bb8b45190f5d 100644
---
a/components/camel-alibaba/camel-alibaba-oss/src/main/docs/alibaba-oss-component.adoc
+++
b/components/camel-alibaba/camel-alibaba-oss/src/main/docs/alibaba-oss-component.adoc
@@ -81,6 +81,8 @@ If any of the above headers are set, they will override their
corresponding quer
=== Consumer
The consumer polls objects from a bucket using `listObjectsV2`, downloads each
object body, and optionally deletes objects after they have been processed when
`deleteAfterRead` is enabled.
+The consumer deletes the object it consumed, whatever the route does with the
`CamelAlibabaOssBucketName` and `CamelAlibabaOssObjectKey` headers.
+A route can set the bucket name header to write a copy of the object to
another bucket.
By default (`includeBody=true`) the consumer reads the content of each object
into a `byte[]`, which is the body, so an object needs as much memory as its
size.
With `includeBody=false` the body is the `InputStream` of the content of the
object instead, which the consumer closes when the exchange is done.
diff --git
a/components/camel-alibaba/camel-alibaba-oss/src/main/java/org/apache/camel/component/alibaba/oss/OSSConsumer.java
b/components/camel-alibaba/camel-alibaba-oss/src/main/java/org/apache/camel/component/alibaba/oss/OSSConsumer.java
index 00d64f5dd277..f78e45b2443d 100644
---
a/components/camel-alibaba/camel-alibaba-oss/src/main/java/org/apache/camel/component/alibaba/oss/OSSConsumer.java
+++
b/components/camel-alibaba/camel-alibaba-oss/src/main/java/org/apache/camel/component/alibaba/oss/OSSConsumer.java
@@ -125,12 +125,15 @@ public class OSSConsumer extends
ScheduledBatchPollingConsumer {
pendingExchanges = total - index - 1;
+ // the object to delete once the exchange is done. It is taken
now, as the route may change or remove the
+ // bucket and key headers before it ends (the producer takes the
bucket to write to from the bucket header)
+ final String bucketName =
exchange.getIn().getHeader(OSSHeaders.BUCKET_NAME, String.class);
final String objectKey =
exchange.getIn().getHeader(OSSHeaders.OBJECT_KEY, String.class);
exchange.getExchangeExtension().addOnCompletion(new
Synchronization() {
@Override
public void onComplete(Exchange exchange) {
try {
- processComplete(exchange);
+ processComplete(bucketName, objectKey);
} finally {
inProgress.remove(objectKey);
}
@@ -287,10 +290,14 @@ public class OSSConsumer extends
ScheduledBatchPollingConsumer {
exchanges.clear();
}
- private void processComplete(Exchange exchange) {
+ /**
+ * Deletes the consumed object, with {@code deleteAfterRead}.
+ *
+ * @param bucketName the bucket the object was consumed from
+ * @param objectKey the key of the consumed object
+ */
+ private void processComplete(String bucketName, String objectKey) {
if (endpoint.isDeleteAfterRead()) {
- String bucketName =
exchange.getIn().getHeader(OSSHeaders.BUCKET_NAME, String.class);
- String objectKey =
exchange.getIn().getHeader(OSSHeaders.OBJECT_KEY, String.class);
if (ObjectHelper.isNotEmpty(bucketName) &&
ObjectHelper.isNotEmpty(objectKey)) {
ossClient.deleteObject(DeleteObjectRequest.newBuilder()
.bucket(bucketName)
diff --git
a/components/camel-alibaba/camel-alibaba-oss/src/test/java/org/apache/camel/component/alibaba/oss/OSSConsumerDeleteAfterReadTest.java
b/components/camel-alibaba/camel-alibaba-oss/src/test/java/org/apache/camel/component/alibaba/oss/OSSConsumerDeleteAfterReadTest.java
new file mode 100644
index 000000000000..3541dc980a0a
--- /dev/null
+++
b/components/camel-alibaba/camel-alibaba-oss/src/test/java/org/apache/camel/component/alibaba/oss/OSSConsumerDeleteAfterReadTest.java
@@ -0,0 +1,150 @@
+/*
+ * 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.alibaba.oss;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import com.aliyun.sdk.service.oss2.OSSClient;
+import com.aliyun.sdk.service.oss2.exceptions.OperationException;
+import com.aliyun.sdk.service.oss2.exceptions.ServiceException;
+import com.aliyun.sdk.service.oss2.models.DeleteObjectRequest;
+import com.aliyun.sdk.service.oss2.models.GetObjectRequest;
+import com.aliyun.sdk.service.oss2.models.GetObjectResult;
+import com.aliyun.sdk.service.oss2.models.ListObjectsV2Request;
+import com.aliyun.sdk.service.oss2.models.ListObjectsV2Result;
+import com.aliyun.sdk.service.oss2.models.ObjectSummary;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.alibaba.oss.constants.OSSHeaders;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+/**
+ * With deleteAfterRead, the consumer deletes the object it consumed, whatever
the route did with the bucket and key
+ * headers.
+ */
+class OSSConsumerDeleteAfterReadTest extends CamelTestSupport {
+
+ private final Set<String> objects = new ConcurrentSkipListSet<>();
+ // the deletes the bucket got, as bucket/key
+ private final List<String> deletes = new CopyOnWriteArrayList<>();
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ context.getRegistry().bind("ossClient", ossClient());
+ return context;
+ }
+
+ @Test
+ void deletesTheConsumedObjectWhenTheRouteSetTheHeaders() throws Exception {
+ objects.add("a.txt");
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("a.txt");
+ // consumed once: deleted, so the later polls must not route it again
+ mock.setAssertPeriod(500);
+
+ // as a route does that writes a copy of the object to another bucket
with the producer
+ addConsumerRoute(new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("alibaba-oss:bucket?ossClient=#ossClient&initialDelay=0&delay=10&deleteAfterRead=true")
+ .convertBodyTo(String.class)
+ .setHeader(OSSHeaders.BUCKET_NAME, constant("archive"))
+ .setHeader(OSSHeaders.OBJECT_KEY,
constant("copy-of-a.txt"))
+ .to("mock:result");
+ }
+ });
+
+ mock.assertIsSatisfied();
+ await().atMost(10, TimeUnit.SECONDS).until(() -> !deletes.isEmpty());
+ assertThat(deletes).containsExactly("bucket/a.txt");
+ assertThat(objects).isEmpty();
+ }
+
+ @Test
+ void deletesTheConsumedObjectWhenTheRouteRemovedTheHeaders() throws
Exception {
+ objects.add("a.txt");
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("a.txt");
+ // consumed once: deleted, so the later polls must not route it again
+ mock.setAssertPeriod(500);
+
+ addConsumerRoute(new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("alibaba-oss:bucket?ossClient=#ossClient&initialDelay=0&delay=10&deleteAfterRead=true")
+ .convertBodyTo(String.class)
+ .removeHeaders("*")
+ .to("mock:result");
+ }
+ });
+
+ mock.assertIsSatisfied();
+ await().atMost(10, TimeUnit.SECONDS).until(() -> !deletes.isEmpty());
+ assertThat(deletes).containsExactly("bucket/a.txt");
+ assertThat(objects).isEmpty();
+ }
+
+ private void addConsumerRoute(RouteBuilder builder) throws Exception {
+ context.addRoutes(builder);
+ }
+
+ private OSSClient ossClient() {
+ OSSClient client = Mockito.mock(OSSClient.class);
+
Mockito.when(client.listObjectsV2(Mockito.any(ListObjectsV2Request.class))).thenAnswer(i
-> {
+ List<ObjectSummary> contents = objects.stream().map(key -> {
+ ObjectSummary summary = Mockito.mock(ObjectSummary.class);
+ Mockito.when(summary.key()).thenReturn(key);
+ return summary;
+ }).toList();
+ ListObjectsV2Result result =
Mockito.mock(ListObjectsV2Result.class);
+ Mockito.when(result.contents()).thenReturn(contents);
+ return result;
+ });
+
Mockito.when(client.getObject(Mockito.any(GetObjectRequest.class))).thenAnswer(i
-> {
+ String key = i.<GetObjectRequest> getArgument(0).key();
+ if (!objects.contains(key)) {
+ throw new OperationException(
+ "GetObject",
ServiceException.newBuilder().statusCode(404).build());
+ }
+ GetObjectResult result = Mockito.mock(GetObjectResult.class);
+ Mockito.when(result.body()).thenReturn(new
ByteArrayInputStream(key.getBytes(StandardCharsets.UTF_8)));
+ return result;
+ });
+
Mockito.when(client.deleteObject(Mockito.any(DeleteObjectRequest.class))).thenAnswer(i
-> {
+ DeleteObjectRequest request = i.getArgument(0);
+ deletes.add(request.bucket() + "/" + request.key());
+ if ("bucket".equals(request.bucket())) {
+ objects.remove(request.key());
+ }
+ return null;
+ });
+ return client;
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSConsumer.java
b/components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSConsumer.java
index b287757c1100..9dd7c953f945 100644
---
a/components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSConsumer.java
+++
b/components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSConsumer.java
@@ -184,12 +184,16 @@ public class OBSConsumer extends
ScheduledBatchPollingConsumer {
// update number of pending exchanges
pendingExchanges = total - index - 1;
+ // the object to move or delete once the exchange is done. It is
taken now, as the route may change or
+ // remove the bucket and key headers before it ends (the producer
takes the bucket to write to from the
+ // bucket name header)
+ final String bucketName =
exchange.getIn().getHeader(OBSHeaders.BUCKET_NAME, String.class);
final String objectKey =
exchange.getIn().getHeader(OBSHeaders.OBJECT_KEY, String.class);
exchange.getExchangeExtension().addOnCompletion(new
Synchronization() {
@Override
public void onComplete(Exchange exchange) {
try {
- processComplete(exchange);
+ processComplete(bucketName, objectKey);
} finally {
inProgress.remove(objectKey);
}
@@ -328,12 +332,13 @@ public class OBSConsumer extends
ScheduledBatchPollingConsumer {
}
/**
- * To handle the exchange after it has been processed
+ * Moves or deletes the consumed object after its exchange has been
processed, with {@code moveAfterRead} or
+ * {@code deleteAfterRead}.
+ *
+ * @param bucketName the bucket the object was consumed from
+ * @param objectKey the key of the consumed object
*/
- private void processComplete(Exchange exchange) {
- String bucketName = exchange.getIn().getHeader(OBSHeaders.BUCKET_NAME,
String.class);
- String objectKey = exchange.getIn().getHeader(OBSHeaders.OBJECT_KEY,
String.class);
-
+ private void processComplete(String bucketName, String objectKey) {
// copy object to destination bucket
if (endpoint.isMoveAfterRead()) {
obsClient.copyObject(bucketName, objectKey,
endpoint.getDestinationBucket(), objectKey);
diff --git
a/components/camel-huawei/camel-huaweicloud-obs/src/test/java/org/apache/camel/component/huaweicloud/obs/OBSConsumerMoveDeleteAfterReadTest.java
b/components/camel-huawei/camel-huaweicloud-obs/src/test/java/org/apache/camel/component/huaweicloud/obs/OBSConsumerMoveDeleteAfterReadTest.java
new file mode 100644
index 000000000000..c78077e5e072
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-obs/src/test/java/org/apache/camel/component/huaweicloud/obs/OBSConsumerMoveDeleteAfterReadTest.java
@@ -0,0 +1,173 @@
+/*
+ * 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.huaweicloud.obs;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketMetadataInfoRequest;
+import com.obs.services.model.BucketMetadataInfoResult;
+import com.obs.services.model.ListObjectsRequest;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.ObsObject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSHeaders;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * With moveAfterRead and deleteAfterRead, the consumer moves and deletes the
object it consumed, whatever the route did
+ * with the bucket name and object key headers.
+ */
+class OBSConsumerMoveDeleteAfterReadTest extends CamelTestSupport {
+
+ private static final String BUCKET = "bucket";
+ private static final String DESTINATION = "processed";
+
+ private final Set<String> objects = new ConcurrentSkipListSet<>();
+ // the copies and deletes the client got, as bucket/key or
bucket/key->bucket/key
+ private final List<String> copies = new CopyOnWriteArrayList<>();
+ private final List<String> deletes = new CopyOnWriteArrayList<>();
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ context.getRegistry().bind("obsClient", obsClient());
+ return context;
+ }
+
+ @Test
+ void movesAndDeletesTheConsumedObjectWhenTheRouteSetTheHeaders() throws
Exception {
+ objects.add("a.txt");
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("a.txt");
+ // consumed once: deleted, so the later polls must not route it again
+ mock.setAssertPeriod(500);
+
+ // a route that changes the bucket and key headers (for example for a
later step of the route)
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from(obsUri())
+ .convertBodyTo(String.class)
+ .setHeader(OBSHeaders.BUCKET_NAME, constant("archive"))
+ .setHeader(OBSHeaders.OBJECT_KEY,
constant("copy-of-a.txt"))
+ .to("mock:result");
+ }
+ });
+
+ mock.assertIsSatisfied();
+ await().atMost(10, TimeUnit.SECONDS).until(() -> !deletes.isEmpty());
+ assertEquals(List.of("bucket/a.txt->processed/a.txt"), copies);
+ assertEquals(List.of("bucket/a.txt"), deletes);
+ assertTrue(objects.isEmpty());
+ }
+
+ @Test
+ void movesAndDeletesTheConsumedObjectWhenTheRouteRemovedTheHeaders()
throws Exception {
+ objects.add("a.txt");
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("a.txt");
+ // consumed once: deleted, so the later polls must not route it again
+ mock.setAssertPeriod(500);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from(obsUri())
+ .convertBodyTo(String.class)
+ .removeHeaders("*")
+ .to("mock:result");
+ }
+ });
+
+ mock.assertIsSatisfied();
+ await().atMost(10, TimeUnit.SECONDS).until(() -> !deletes.isEmpty());
+ assertEquals(List.of("bucket/a.txt->processed/a.txt"), copies);
+ assertEquals(List.of("bucket/a.txt"), deletes);
+ assertTrue(objects.isEmpty());
+ }
+
+ private String obsUri() {
+ return "hwcloud-obs:?bucketName=" + BUCKET +
"&obsClient=#obsClient&initialDelay=0&delay=10"
+ + "&moveAfterRead=true&destinationBucket=" + DESTINATION +
"&deleteAfterRead=true";
+ }
+
+ private ObsClient obsClient() {
+ ObsClient client = Mockito.mock(ObsClient.class);
+ // the source and the destination bucket exist, in the same location
+ BucketMetadataInfoResult metadata =
Mockito.mock(BucketMetadataInfoResult.class);
+ Mockito.when(metadata.getLocation()).thenReturn("cn-north-4");
+
Mockito.when(client.getBucketMetadata(Mockito.any(BucketMetadataInfoRequest.class))).thenReturn(metadata);
+
Mockito.when(client.listObjects(Mockito.any(ListObjectsRequest.class))).thenAnswer(i
-> {
+ // listed objects carry no content type, so the consumer gets each
of them
+ List<ObsObject> listed = objects.stream().map(key -> {
+ ObsObject summary = new ObsObject();
+ summary.setBucketName(BUCKET);
+ summary.setObjectKey(key);
+ return summary;
+ }).toList();
+ ObjectListing listing = Mockito.mock(ObjectListing.class);
+ Mockito.when(listing.getObjects()).thenReturn(listed);
+ return listing;
+ });
+ Mockito.when(client.getObject(Mockito.eq(BUCKET),
Mockito.anyString())).thenAnswer(i -> {
+ String key = i.getArgument(1);
+ if (!objects.contains(key)) {
+ ObsException e = new ObsException("NoSuchKey");
+ e.setResponseCode(404);
+ throw e;
+ }
+ ObsObject object = new ObsObject();
+ object.setBucketName(BUCKET);
+ object.setObjectKey(key);
+ ObjectMetadata metadata1 = new ObjectMetadata();
+ metadata1.setContentType("text/plain");
+ object.setMetadata(metadata1);
+ object.setObjectContent(new
ByteArrayInputStream(key.getBytes(StandardCharsets.UTF_8)));
+ return object;
+ });
+ Mockito.when(client.copyObject(Mockito.anyString(),
Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))
+ .thenAnswer(i -> {
+ copies.add(i.getArgument(0) + "/" + i.getArgument(1) +
"->" + i.getArgument(2) + "/" + i.getArgument(3));
+ return null;
+ });
+ Mockito.when(client.deleteObject(Mockito.anyString(),
Mockito.anyString())).thenAnswer(i -> {
+ deletes.add(i.getArgument(0) + "/" + i.getArgument(1));
+ if (BUCKET.equals(i.getArgument(0))) {
+ objects.remove(i.<String> getArgument(1));
+ }
+ return null;
+ });
+ return client;
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index af92999f5615..b9396bc4ce7d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -7136,6 +7136,20 @@ The consumers now call `processCommit(Exchange, String)`
with the name of the ob
of `GoogleCloudStorageConsumer`, `MinioConsumer` or `MNSConsumer` that
overrides `processCommit(Exchange)` must override
the new method instead. `processCommit(Exchange)` is deprecated.
+=== camel-alibaba-oss, camel-huaweicloud-obs - the consumer deletes or moves
what it consumed
+
+With `deleteAfterRead`, the `alibaba-oss` consumer now deletes the object it
consumed. Before, it took the bucket and
+the key from the `CamelAlibabaOssBucketName` and `CamelAlibabaOssObjectKey`
headers as the route left them. The
+producer writes to the bucket of the `CamelAlibabaOssBucketName` header, so a
route that set it to write a copy of the
+object to another bucket deleted the object with the same key in that bucket,
and the consumed object was consumed
+again by the next poll. A route that removed these headers, or replaced the
message, deleted nothing.
+
+With `moveAfterRead` and `deleteAfterRead`, the `hwcloud-obs` consumer now
copies and deletes the object it consumed.
+Before, it took the bucket and the key from the `CamelHwCloudObsBucketName`
and `CamelHwCloudObsObjectKey` headers as
+the route left them: a route that changed them copied and deleted another
object, and a route that removed them, or
+replaced the message, copied and deleted nothing, so the consumed object was
consumed again by the next poll. (The
+`hwcloud-obs` producer takes its bucket from the exchange property of that
name, not from the header.)
+
=== camel-mongodb - connectionUriString without hosts creates the client of
the endpoint
An endpoint that sets `connectionUriString` without `hosts` now creates its
client from the connection string. Before,