2012-12-02 83 views
3

駱駝V2.8(駱駝-AWS/SQS)Apache的駱駝AWS/SQS部件

是有可能使用駱駝AWS-SQS部件將消息發送到一個共享隊列?

我能夠直接發送到myQueue中而不是其他隊列,我有機會獲得通過SQS訪問策略,並確認它直接通過捲曲

駱駝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 

不駱駝AWS-SQS v2.8提供了這種功能?

謝謝。

回答

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,但我用更簡單的方法工作。