apache camel - aws s3中的凭据无效

时间:2014-03-28 06:36:13

标签: amazon-web-services amazon-s3 apache-camel

我如何处理驼峰上的无效访问/密钥?

我已经尝试过errorHandler骆驼,但由于交换信息失败而导致错误,而这个问题甚至发生在交流之前。

我也尝试了pollingStrategy,我似乎能够抓住rollback()上的错误。我的问题是,即使方法返回false,它仍然会继续重试。我还需要指定重试之间的延迟,我是否需要在实现PollingConsumerPollStrategy的课程中自行实现?

@Override
public boolean rollback(Consumer consumer, Endpoint endpoint, int retryCounter, Exception e) throws Exception {
    System.out.println("retryCounter " + retryCounter);
    if (retryCounter < 3) {
        // return true to tell Camel that it should retry the poll immediately
        return true;
    }
    // okay we give up do not retry anymore
    return false;
}


14:20:26.406 WARN  o.a.c.component.aws.s3.S3Consumer [Camel (camelContext) thread #0 - aws-s3://thebucket] - log:224 - Consumer S3Consumer[aws-s3://thebucket?amazonS3Client=%23s3Client] failed polling endpoint: Endpoint[aws-s3://thebucket?amazonS3Client=%23s3Client]. Will try again at next poll. Caused by: [com.amazonaws.services.s3.model.AmazonS3Exception - The AWS Access Key Id you provided does not exist in our records.]
com.amazonaws.services.s3.model.AmazonS3Exception: The AWS Access Key Id you provided does not exist in our records.
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:659) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:347) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2994) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2965) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:481) ~[aws-java-sdk-1.5.1.jar:na]
    at org.apache.camel.component.aws.s3.S3Consumer.poll(S3Consumer.java:69) ~[camel-aws-2.12.1.jar:2.12.1]
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187) [camel-core-2.12.1.jar:2.12.1]
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114) [camel-core-2.12.1.jar:2.12.1]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_45]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) [na:1.7.0_45]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_45]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_45]
    at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
14:20:27.927 WARN  o.a.c.component.aws.s3.S3Consumer [Camel (camelContext) thread #0 - aws-s3://thebucket] - log:224 - Consumer S3Consumer[aws-s3://thebucket?amazonS3Client=%23s3Client] failed polling endpoint: Endpoint[aws-s3://thebucket?amazonS3Client=%23s3Client]. Will try again at next poll. Caused by: [com.amazonaws.services.s3.model.AmazonS3Exception - The AWS Access Key Id you provided does not exist in our records.]
com.amazonaws.services.s3.model.AmazonS3Exception: The AWS Access Key Id you provided does not exist in our records.
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:659) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:347) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2994) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2965) ~[aws-java-sdk-1.5.1.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:481) ~[aws-java-sdk-1.5.1.jar:na]
    at org.apache.camel.component.aws.s3.S3Consumer.poll(S3Consumer.java:69) ~[camel-aws-2.12.1.jar:2.12.1]
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187) [camel-core-2.12.1.jar:2.12.1]
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114) [camel-core-2.12.1.jar:2.12.1]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_45]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) [na:1.7.0_45]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_45]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_45]
    at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]

非常感谢!

1 个答案:

答案 0 :(得分:-1)

如果您使用的是camel 2.12.x或camel 2.13.0,则可以尝试设置backoff*的URI选项。