gpt4 book ai didi

java - Camel AWS SNS 异常(exception)

转载 作者:行者123 更新时间:2023-12-02 02:17:17 24 4
gpt4 key购买 nike

我正在尝试使用 Apache Camel 通过 Camel sns 库发送 SNS。

我使用了此处找到的文档 http://camel.apache.org/aws-sns.html

它说我需要定义一个客户端,然后将其绑定(bind)到注册表。因此我使用以下代码完成了此操作:

BasicAWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3 client = AmazonS3Client.builder().withRegion("eu-west-1")
.withCredentials(new AWSStaticCredentialsProvider(creds))
.build();

CamelContext context = new DefaultCamelContext();
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry)context.getRegistry()).getRegistry();
registry.bind("client", client);

接下来,在我的 Camel 路线内,我正在执行此操作

from(mySftp.getUri("/camel"))
to("aws-sns://"+topicArn+"?amazonSNSClient=#client")

使用此代码,我收到此错误 -

Failed to create route route1 at: >>> To[aws-sns://arn:aws:sns:eu-west-1:xxxxxx?amazonSNSClient=#client] <<< in route: Route(route1)[[From[sftp://xxxxxxxx... because of Failed to resolve endpoint: aws-sns://arn:aws:sns:eu-west-1:xxxxxxxx?amazonSNSClient=%23client due to: Could not find a suitable setter for property: amazonSNSClient as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: com.amazonaws.services.sns.AmazonSNS with value #client

除此之外,我还尝试使用以下 Camel 路由发送 sns

.to("aws-sns://"+topicArn+"?accessKey="+accessKey+"&secretKey="+secretKey+"&amazonSNSEndpoint="+snsEndpoint)

但是它告诉我没有提供任何区域,尽管我的 snsEnpoint 设置为 - sns.eu-west-1.amazonaws.com

有人知道为什么我无法以我尝试的任何方式使用camel发送sns吗?

提前致谢

最佳答案

您正在绑定(bind) AmazonS3Client,但它需要 AmazonSNSClient

Camel 无法将对 AmazonS3Client 的引用转换为 AmazonSNSClient 的实例。

参见http://camel.apache.org/aws-sns.html#AWS-SNS-AdvancedAmazonSNSconfiguration

关于java - Camel AWS SNS 异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49128174/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com