Reputation: 81
Camel v2.8 (camel-aws/sqs)
is it possible to send messages to a shared queue using camel aws-sqs component?
I am able to send directly to myQueue but not other Queues which I have access to via SQS access policy and confirmed that it works directly via CURL
Camel aws-sqs endpoint URL and route that works looks like this:
from("someplace").to("aws-sqs://myQueue?amazonSQSEndpoint=" + endpoint + "&accessKey=" + accessKey +"&secretKey=" + secretKey);
I need to be able to send to a shared Queue while providing a URL in the following format:
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
Does Camel aws-sqs v2.8 provides this functionality?
Thank you.
Upvotes: 7
Views: 2747
Reputation: 688
This may not be the best option because it limits the client, but I was already creating and registering an AmazonSQSClient (to use in the route definition parameter amazonSQSClient). I created a subclass to override listQueues to instead make a call to getQueueURL which has a QueueOwnerAWSAccountId parameter. Here is my custom client:
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();
}
}
}
The better option would be to override org.apache.camel.component.aws.sqs.SqsEndpoint.doStart, but I am working with the easier approach.
Upvotes: 0