You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/12/25 04:35:09 UTC
git commit: CAMEL-6623 Supporting to access the SQS which user don't
have right to list, with thanks to Chris
Updated Branches:
refs/heads/master 19b05db67 -> d9673703e
CAMEL-6623 Supporting to access the SQS which user don't have right to list, with thanks to Chris
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d9673703
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d9673703
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d9673703
Branch: refs/heads/master
Commit: d9673703ec7fbd1a1c6764e8603a94836961d049
Parents: 19b05db
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Dec 25 11:34:47 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Dec 25 11:34:47 2013 +0800
----------------------------------------------------------------------
.../component/aws/sqs/SqsConfiguration.java | 33 +++++++++++++-------
.../camel/component/aws/sqs/SqsEndpoint.java | 7 ++++-
.../aws/sqs/SqsComponentConfigurationTest.java | 5 ++-
3 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d9673703/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
index 87f102c..2c587cf 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
@@ -22,7 +22,7 @@ import com.amazonaws.services.sqs.AmazonSQS;
/**
* The AWS SQS component configuration properties
- *
+ *
*/
public class SqsConfiguration {
@@ -33,7 +33,7 @@ public class SqsConfiguration {
private String secretKey;
private String amazonSQSEndpoint;
private String queueOwnerAWSAccountId;
-
+ private String region;
// consumer properties
private Boolean deleteAfterRead = Boolean.TRUE;
private Boolean deleteIfFiltered = Boolean.TRUE;
@@ -42,20 +42,20 @@ public class SqsConfiguration {
private Integer waitTimeSeconds;
private Integer defaultVisibilityTimeout;
private Boolean extendMessageVisibility = Boolean.FALSE;
-
+
// producer properties
private Integer delaySeconds;
-
+
// queue properties
private Integer maximumMessageSize;
private Integer messageRetentionPeriod;
private Integer receiveMessageWaitTimeSeconds;
private String policy;
-
+
public void setAmazonSQSEndpoint(String amazonSQSEndpoint) {
this.amazonSQSEndpoint = amazonSQSEndpoint;
}
-
+
public String getAmazonSQSEndpoint() {
return amazonSQSEndpoint;
}
@@ -99,7 +99,7 @@ public class SqsConfiguration {
public void setAmazonSQSClient(AmazonSQS amazonSQSClient) {
this.amazonSQSClient = amazonSQSClient;
}
-
+
public Integer getVisibilityTimeout() {
return visibilityTimeout;
}
@@ -107,7 +107,7 @@ public class SqsConfiguration {
public void setVisibilityTimeout(Integer visibilityTimeout) {
this.visibilityTimeout = visibilityTimeout;
}
-
+
public Collection<String> getAttributeNames() {
return attributeNames;
}
@@ -115,7 +115,7 @@ public class SqsConfiguration {
public void setAttributeNames(Collection<String> attributeNames) {
this.attributeNames = attributeNames;
}
-
+
public Integer getDefaultVisibilityTimeout() {
return defaultVisibilityTimeout;
}
@@ -147,7 +147,7 @@ public class SqsConfiguration {
public void setMessageRetentionPeriod(Integer messageRetentionPeriod) {
this.messageRetentionPeriod = messageRetentionPeriod;
}
-
+
public String getPolicy() {
return policy;
}
@@ -179,7 +179,7 @@ public class SqsConfiguration {
public void setWaitTimeSeconds(Integer waitTimeSeconds) {
this.waitTimeSeconds = waitTimeSeconds;
}
-
+
public String getQueueOwnerAWSAccountId() {
return queueOwnerAWSAccountId;
}
@@ -196,12 +196,20 @@ public class SqsConfiguration {
this.deleteIfFiltered = deleteIfFiltered;
}
+ public String getRegion() {
+ return region;
+ }
+
+ public void setRegion(String region) {
+ this.region = region;
+ }
+
@Override
public String toString() {
return "SqsConfiguration[queueName=" + queueName
+ ", amazonSQSClient=" + amazonSQSClient
+ ", accessKey=" + accessKey
- + ", secretKey=xxxxxxxxxxxxxxx"
+ + ", secretKey=xxxxxxxxxxxxxxx"
+ ", deleteAfterRead=" + deleteAfterRead
+ ", deleteIfFiltered=" + deleteIfFiltered
+ ", visibilityTimeout=" + visibilityTimeout
@@ -215,6 +223,7 @@ public class SqsConfiguration {
+ ", policy=" + policy
+ ", extendMessageVisibility=" + extendMessageVisibility
+ ", queueOwnerAWSAccountId=" + queueOwnerAWSAccountId
+ + ", region=" + region
+ "]";
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/d9673703/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
index e43b07f..7f6bf46 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
@@ -80,7 +80,12 @@ public class SqsEndpoint extends ScheduledPollEndpoint {
client = getConfiguration().getAmazonSQSClient() != null
? getConfiguration().getAmazonSQSClient() : getClient();
- if (configuration.getQueueOwnerAWSAccountId() != null) {
+ // If both region and Account ID is provided the queue URL can be built manually.
+ // This allows accessing queues where you don't have permission to list queues or query queues
+ if (configuration.getRegion() != null && configuration.getQueueOwnerAWSAccountId() != null) {
+ queueUrl = "https://sqs." + configuration.getRegion() + ".amazonaws.com/" +
+ configuration.getQueueOwnerAWSAccountId() + "/" + configuration.getQueueName();
+ } else if (configuration.getQueueOwnerAWSAccountId() != null) {
GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest();
getQueueUrlRequest.setQueueName(configuration.getQueueName());
getQueueUrlRequest.setQueueOwnerAWSAccountId(configuration.getQueueOwnerAWSAccountId());
http://git-wip-us.apache.org/repos/asf/camel/blob/d9673703/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
index 5a591e9..9414cee 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
@@ -42,6 +42,7 @@ public class SqsComponentConfigurationTest extends CamelTestSupport {
assertNull(endpoint.getConfiguration().getMaximumMessageSize());
assertNull(endpoint.getConfiguration().getMessageRetentionPeriod());
assertNull(endpoint.getConfiguration().getPolicy());
+ assertNull(endpoint.getConfiguration().getRegion());
}
@Test
@@ -64,6 +65,7 @@ public class SqsComponentConfigurationTest extends CamelTestSupport {
assertNull(endpoint.getConfiguration().getMaximumMessageSize());
assertNull(endpoint.getConfiguration().getMessageRetentionPeriod());
assertNull(endpoint.getConfiguration().getPolicy());
+ assertNull(endpoint.getConfiguration().getRegion());
}
@Test
@@ -80,7 +82,7 @@ public class SqsComponentConfigurationTest extends CamelTestSupport {
+ "%7B%22Version%22%3A%222008-10-17%22%2C%22Id%22%3A%22%2F195004372649%2FMyQueue%2FSQSDefaultPolicy%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22Queue1ReceiveMessage%22%2C%22"
+ "Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22AWS%22%3A%22*%22%7D%2C%22Action%22%3A%22SQS%3AReceiveMessage%22%2C%22Resource%22%3A%22%2F195004372649%2FMyQueue%22%7D%5D%7D"
+ "&delaySeconds=123&receiveMessageWaitTimeSeconds=10&waitTimeSeconds=20"
- + "&queueOwnerAWSAccountId=111222333");
+ + "&queueOwnerAWSAccountId=111222333®ion=us-east-1");
assertEquals("MyQueue", endpoint.getConfiguration().getQueueName());
assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
@@ -99,6 +101,7 @@ public class SqsComponentConfigurationTest extends CamelTestSupport {
assertEquals(Integer.valueOf(10), endpoint.getConfiguration().getReceiveMessageWaitTimeSeconds());
assertEquals(Integer.valueOf(20), endpoint.getConfiguration().getWaitTimeSeconds());
assertEquals("111222333", endpoint.getConfiguration().getQueueOwnerAWSAccountId());
+ assertEquals("us-east-1", endpoint.getConfiguration().getRegion());
}
@Test