我正在尝试创建一个骆驼路由来将文件从 FTP 服务器传输到 AWS S3 存储。我写了以下路线
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception
{
from("sftp://<<ftp_server_name>>&noop=true&include=<<file_name>>...")
.process(new Processor(){
@Override
public void process(Exchange ex)
{
System.out.println("Hello");
}
})
.to("aws-s3://my-dev-bucket ?
accessKey=ABC***********&secretKey=12abc********+**********");
}
问题是,这给了我以下例外:
Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[aws-s3://my-dev-bucket?accessKey=ABC*******************&secretKey=123abc******************** <<< in route: Route(route1)[[From[sftp://<<ftp-server>>... because of Failed to resolve endpoint: aws-s3://my-dev-bucket?accessKey=ABC***************&secretKey=123abc************** due to: The request signature we calculated does not match the signature you provided. Check your key and signing method.
然后我尝试以另一种方式做到这一点。即编写这样的方法:
public void boot() throws Exception {
// create a Main instance
main = new Main();
// enable hangup support so you can press ctrl + c to terminate the JVM
main.enableHangupSupport();
// bind MyBean into the registery
main.bind("foo", new MyBean());
// add routes
AWSCredentials awsCredentials = new BasicAWSCredentials("ABC*****************", "123abc*************************");
AmazonS3 client = new AmazonS3Client(awsCredentials);
//main.bind("client", client);
main.addRouteBuilder(new MyRouteBuilder());
main.run();
}
并使用绑定变量#client 调用。这种方法没有给出任何异常,但是文件传输不起作用。
为了确保我的方法没有问题,我尝试了 aws-sqs 而不是 aws-s3 并且效果很好(文件成功传输到 SQS 队列)
知道为什么会这样吗?骆驼的“aws-s3”连接器是否存在一些基本问题?