Camel v2.8(camel-aws / sqs)
是否可以使用camel aws-sqs组件将消息发送到共享队列?
我可以直接发送到myQueue,但不能通过SQS访问策略发送我可以访问的其他队列,并确认它可以通过CURL直接使用
Camel aws-sqs端点URL和工作路由如下所示:
from("someplace").to("aws-sqs://myQueue?amazonSQSEndpoint=" + endpoint + "&accessKey=" + accessKey +"&secretKey=" + secretKey);
我需要能够在提供以下格式的网址时发送到共享队列:
https://sqs.us-west-1.amazonaws.com/111222333444/sharedQueue?Action=SendMessage
&MessageBody=test
&Version=2011-10-01
&Timestamp=2012-1201T22%3A01%3A15Z
&Signature=Kl0Vki0KzvoB6Z2NUHFT7mxsurCn%2FjPHv4%2BJ8LEo7NA%3D
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&AWSAccessKeyId=AKIXJMGM5GYMGSTANQ8A
Camel aws-sqs v2.8是否提供此功能?
谢谢。
答案 0 :(得分:0)
这可能不是最佳选择,因为它限制了客户端,但我已经创建并注册了AmazonSQSClient(用于路由定义参数amazonSQSClient)。我创建了一个子类来覆盖listQueues,而是调用getQueueURL,它具有QueueOwnerAWSAccountId参数。这是我的自定义客户端:
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.services.sqs.AmazonSQSClient;
import com.amazonaws.services.sqs.model.GetQueueUrlRequest;
import com.amazonaws.services.sqs.model.GetQueueUrlResult;
import com.amazonaws.services.sqs.model.ListQueuesResult;
public class CustomSQSClient extends AmazonSQSClient {
private String queueName;
private String accountId;
public CustomSQSClient(AWSCredentials awsCredentials, ClientConfiguration clientConfiguration, String queueName, String accountId) {
super(awsCredentials, clientConfiguration);
this.queueName = queueName;
this.accountId = accountId;
}
@Override
public ListQueuesResult listQueues() throws AmazonServiceException,
AmazonClientException {
GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest();
getQueueUrlRequest.setQueueName(queueName);
getQueueUrlRequest.setQueueOwnerAWSAccountId(accountId);
GetQueueUrlResult getQueueUrlResult = getQueueUrl(getQueueUrlRequest );
if (getQueueUrlResult.getQueueUrl() != null) {
ListQueuesResult listQueuesResult = new ListQueuesResult();
listQueuesResult.getQueueUrls().add(getQueueUrlResult.getQueueUrl());
return listQueuesResult;
} else {
return super.listQueues();
}
}
}
更好的选择是覆盖org.apache.camel.component.aws.sqs.SqsEndpoint.doStart,但我正在使用更简单的方法。