有沒有辦法消耗S3存儲桶中的所有文件而不從S3中刪除文件(在S3中,大約有15,000個文件)?使用aws S3中的所有文件,其中deleteAfterRead = false
隨着noop參數在aws-s3中的滯後,下列配置有問題。那個問題是:它不斷地一遍又一遍地檢索相同的5個文件。
<endpoint id="fbPage" uri="aws-s3://bucket?amazonS3Client=#aws-credential&deleteAfterRead=false&maxMessagesPerPoll=5&prefix=dev/facebook/page"/>
<route id="consumeS3FbPage">
<from uri="ref:fbPage"/>
<choice>
<when>
<simple>${header.CamelAwsS3ContentLength} > 0</simple>
<log message="Page File detected: ${header.CamelAwsS3Key}"/>
<bean ref="dfaReportingRePull" method="s3toElasticFormat"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="http://localhost:9200/fb_camel/page/_bulk"/>
<log message="Success"/>
</when>
<when>
<simple>${header.CamelAwsS3ContentLength} == 0</simple>
<log message="Empty content, Probably the s3 key Folder itself: ${header.CamelAwsS3Key}"/>
</when>
</choice>
</route>
以下日誌給出了同一文件中檢索一遍又一遍:
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:46,904 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/05/31/9c9537e6-12a3-415e-aa3d-a450011008be.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:46,993 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:46,994 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/01/97d85443-74af-4d64-9808-a4500110117a.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:47,002 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:47,002 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/02/223410b2-b4ce-4b7f-8e47-a45001101254.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:47,010 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:47,011 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/03/e5c21710-d764-453d-9736-a4500110132e.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:47,019 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:47,019 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/04/851d3759-0c35-4679-838c-a4500110140b.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:47,027 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,375 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/05/31/9c9537e6-12a3-415e-aa3d-a450011008be.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,396 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,397 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/01/97d85443-74af-4d64-9808-a4500110117a.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,409 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,410 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/02/223410b2-b4ce-4b7f-8e47-a45001101254.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,419 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,420 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/03/e5c21710-d764-453d-9736-a4500110132e.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,429 INFO consumeS3FbPage - Success
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,430 INFO consumeS3FbPage - Page File detected: dev/facebook/page/166866083481130/2014/06/04/851d3759-0c35-4679-838c-a4500110140b.json
[Camel (camel-1) thread #0 - aws-s3://bucket] 21:26:51,439 INFO consumeS3FbPage - Success
即使我使用冪等,它只是檢測到所有的5個文件是重複的,因此被忽略。
我不知道如果我做deleteAfterRead,並把它放回工作?不,當我查看http://camel.465427.n5.nabble.com/camel-aws-s3-get-only-files-I-need-td5714095.html中的代碼時,似乎代碼只會循環顯示aws s3當前返回列表中的列表。
當我看代碼ListObjectsRequest.java,我看到有一種方法來定義一個標記,它表明哪個是最後處理的s#鍵。有沒有辦法通過Camel Spring DSL獲得這個市場? [更新]沒有。
深入瞭解代碼後,我找到了導致這種情況的根本原因。並通過這個JIRA票可跟蹤:https://issues.apache.org/jira/browse/CAMEL-8431
注:駱駝的版本是2.14.0