Federico Mariani created CAMEL-27064:
----------------------------------------

             Summary: camel-google-storage, camel-minio, camel-alibaba-mns - 
the consumers delete or move the object named by the headers as the route left 
them, not the one they consumed
                 Key: CAMEL-27064
                 URL: https://issues.apache.org/jira/browse/CAMEL-27064
             Project: Camel
          Issue Type: Bug
          Components: camel-google-storage, camel-minio
            Reporter: Federico Mariani


With {{deleteAfterRead}} or {{moveAfterRead}}, three consumers take what to 
delete or move from the message headers when the exchange completes, not from 
what they consumed:
* google-storage: the {{CamelGoogleCloudStorageObjectName}} and 
{{CamelGoogleCloudStorageBucketName}} headers 
({{GoogleCloudStorageConsumer.processCommit}}).
* minio: the {{CamelMinioObjectName}} and {{CamelMinioBucketName}} headers 
({{MinioConsumer.processCommit}}).
* alibaba-mns: the {{CamelAlibabaMnsReceiptHandle}} header 
({{MNSConsumer.processCommit}}).

A route that sets the object name header, for example to write a copy of the 
object under another name (the google-storage and minio producers take the name 
from the same header), deletes or moves its copy. The consumed object stays, 
and the next poll consumes it again.

A route that removes the Camel headers, or replaces the message, leaves the 
object or the message in place:
* google-storage: the delete of a null name fails ({{NullPointerException}}), 
and the exception handler of the consumer logs it as a WARN.
* minio: the client rejects the null bucket name ({{NullPointerException: 
bucket name must not be null}}). {{processCommit}} only catches 
{{MinioException}}, so the failure does not reach the exception handler of the 
consumer: it is logged as a WARN and ignored.
* alibaba-mns: the consumer does not delete the message. It is received again 
once it is visible again, every time.

{code:java}
from("google-storage://bucket?prefix=inbox/")
    .setHeader(GoogleCloudStorageConstants.OBJECT_NAME, 
simple("done/${header.CamelGoogleCloudStorageObjectName}"))
    .to("google-storage://bucket"); // deletes done/inbox/a.txt, inbox/a.txt is 
consumed again

from("minio://bucket?prefix=inbox/&moveAfterRead=true&destinationBucketName=archive")
    .setHeader(MinioConstants.OBJECT_NAME, 
simple("done/${header.CamelMinioObjectName}"))
    .to("minio://bucket"); // moves done/inbox/a.txt to archive, inbox/a.txt is 
consumed again

from("alibaba-mns:queue")
    .removeHeaders("*")
    .to("http://backend";); // the message is never deleted
{code}

Expected: the consumer deletes or moves the object or message it consumed, as 
CAMEL-27015 does for aws2-s3, azure-storage-blob and aws2-sqs. It takes the 
object name or the receipt handle when it consumes the message, before the 
route runs, and the bucket or queue of the endpoint.

_Claude Code on behalf of Federico Mariani_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to