事實上,Alex Nano寫道,s3文件夾只是對象鍵(「文件名」)的前綴,所以如果你想設置多個路由來監視不同的s3「文件夾」,你可以使用前綴選項的aws:s3端點
前綴工作在相同的功能,你會使用aws s3 cli,
aws s3 ls s3://mybucket/myfolderInsideBucket/
甲JUnit示例
public class CamelAwsS3Test extends CamelTestSupport {
@EndpointInject(uri = "mock:result")
private MockEndpoint resultEndpoint;
@Before
public void setup() throws Exception {
context.start();
}
@Test
public void foo() throws Exception {
int expectedFileCount = 3
resultEndpoint.expectedMessageCount(expectedFileCount);
resultEndpoint.assertIsSatisfied();
}
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
final String accessKey = "ACCESSKEY";
final String secretKey = "SECRETKEY";
AmazonS3 client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey));
registry.bind("amazonS3Client", client);
return registry;
}
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("aws-s3://{BUCKET}?amazonS3Client=#amazonS3Client&prefix=${FOLDER}")
.log("hey ${body}").to("mock:result");
}
};
}
}
你的邏輯是實心的,但是,它需要使自定義擴展/黑客駱駝庫。讓我看看我能否以這種方式找到任何使用謂詞的人。 –