Repository: camel Updated Branches: refs/heads/master 358914ce5 -> b66dfe73c
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/b66dfe73 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b66dfe73 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b66dfe73 Branch: refs/heads/master Commit: b66dfe73ccb848b40287489cb0e38cced8b1683f Parents: 358914c Author: Willem Jiang <[email protected]> Authored: Wed Mar 4 20:59:22 2015 +0800 Committer: Willem Jiang <[email protected]> Committed: Wed Mar 4 21:01:31 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/b66dfe73/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); }
