Repository: camel Updated Branches: refs/heads/camel-2.13.x 813186222 -> e75356c31 refs/heads/camel-2.14.x 0568b1202 -> 38c3de7f5
CAMEL-8431 Fixed the issue that camel-aws consume the same files in aws S3 bucket where deleteAfterRead = false with thanks to Yap Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/38c3de7f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/38c3de7f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/38c3de7f Branch: refs/heads/camel-2.14.x Commit: 38c3de7f549bf4c651886b8249ebfa406e3df780 Parents: 0568b12 Author: Willem Jiang <[email protected]> Authored: Wed Mar 4 20:59:22 2015 +0800 Committer: Willem Jiang <[email protected]> Committed: Wed Mar 4 21:54:03 2015 +0800 ---------------------------------------------------------------------- .../org/apache/camel/component/aws/s3/S3Consumer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/38c3de7f/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java index 3289d36..73656e4 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Consumer.java @@ -48,6 +48,7 @@ import org.slf4j.LoggerFactory; public class S3Consumer extends ScheduledBatchPollingConsumer { private static final Logger LOG = LoggerFactory.getLogger(S3Consumer.class); + private String marker; public S3Consumer(S3Endpoint endpoint, Processor processor) throws NoFactoryAvailableException { super(endpoint, processor); @@ -75,9 +76,16 @@ public class S3Consumer extends ScheduledBatchPollingConsumer { listObjectsRequest.setBucketName(bucketName); listObjectsRequest.setPrefix(getConfiguration().getPrefix()); listObjectsRequest.setMaxKeys(maxMessagesPerPoll); + if (marker != null && !getConfiguration().isDeleteAfterRead()) { + listObjectsRequest.setMarker(marker); + } ObjectListing listObjects = getAmazonS3Client().listObjects(listObjectsRequest); - + // we only setup the marker if the file is not deleted + if (!getConfiguration().isDeleteAfterRead()) { + // where marker is track + marker = listObjects.getMarker(); + } if (LOG.isTraceEnabled()) { LOG.trace("Found {} objects in bucket [{}]...", listObjects.getObjectSummaries().size(), bucketName); }
