7

Camel v2.8 (camel-aws/sqs)

是否可以使用骆驼 aws-sqs 组件将消息发送到共享队列?

我可以直接发送到 myQueue 但不能发送到我可以通过 SQS 访问策略访问的其他队列,并确认它直接通过 CURL 工作

Camel aws-sqs 端点 URL 和有效路由如下所示:

from("someplace").to("aws-sqs://myQueue?amazonSQSEndpoint=" + endpoint + "&accessKey=" +       accessKey +"&secretKey=" + secretKey);

我需要能够发送到共享队列,同时提供以下格式的 URL:

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 是否提供此功能?

谢谢你。

4

1 回答 1

0

这可能不是最佳选择,因为它限制了客户端,但我已经创建并注册了一个 AmazonSQSClient(在路由定义参数 amazonSQSClient 中使用)。我创建了一个子类来覆盖 listQueues 来调用具有 QueueOwnerAWSAccountId 参数的 getQueueURL。这是我的自定义客户端:

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,但我正在使用更简单的方法。

于 2013-08-07T20:40:09.280 回答