You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/03/25 08:52:01 UTC

camel git commit: CAMEL-11070: camel-aws - SQS allow to configure AWS hostname.

Repository: camel
Updated Branches:
  refs/heads/master b33d80bc6 -> 2e839f0c9


CAMEL-11070: camel-aws - SQS allow to configure AWS hostname.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2e839f0c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2e839f0c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2e839f0c

Branch: refs/heads/master
Commit: 2e839f0c9a3f4c51d98751c7982d4c765f66ecc5
Parents: b33d80b
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Mar 25 09:51:54 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Mar 25 09:51:54 2017 +0100

----------------------------------------------------------------------
 .../src/main/docs/aws-sqs-component.adoc        |  7 ++++---
 .../component/aws/sqs/SqsConfiguration.java     | 20 +++++++++++++++++---
 .../camel/component/aws/sqs/SqsEndpoint.java    |  6 +++++-
 3 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2e839f0c/components/camel-aws/src/main/docs/aws-sqs-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/docs/aws-sqs-component.adoc b/components/camel-aws/src/main/docs/aws-sqs-component.adoc
index 29abe52..199329e 100644
--- a/components/camel-aws/src/main/docs/aws-sqs-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-sqs-component.adoc
@@ -51,18 +51,17 @@ with the following path and query parameters:
 | **queueNameOrArn** | *Required* Queue name or ARN |  | String
 |=======================================================================
 
-#### Query Parameters (44 parameters):
+#### Query Parameters (45 parameters):
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |=======================================================================
 | Name | Description | Default | Type
-| **accessKey** (common) | Amazon AWS Access Key |  | String
+| **amazonAWSHost** (common) | The hostname of the Amazon AWS cloud. | amazonaws.com | String
 | **amazonSQSClient** (common) | To use the AmazonSQS as client |  | AmazonSQS
 | **amazonSQSEndpoint** (common) | The region with which the AWS-SQS client wants to work with. Only works if Camel creates the AWS-SQS client i.e. if you explicitly set amazonSQSClient then this setting will have no effect. You would have to set it on the client you create directly |  | String
 | **headerFilterStrategy** (common) | To use a custom HeaderFilterStrategy to map headers to/from Camel. |  | HeaderFilterStrategy
 | **queueOwnerAWSAccountId** (common) | Specify the queue owner aws account id when you need to connect the queue with different account owner. |  | String
 | **region** (common) | Specify the queue region which could be used with queueOwnerAWSAccountId to build the service URL. |  | String
-| **secretKey** (common) | Amazon AWS Secret Key |  | String
 | **attributeNames** (consumer) | A list of attribute names to receive when consuming. Multiple names can be separated by comma. |  | String
 | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean
 | **concurrentConsumers** (consumer) | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | int
@@ -100,6 +99,8 @@ with the following path and query parameters:
 | **policy** (queue) | The policy for this queue |  | String
 | **receiveMessageWaitTime Seconds** (queue) | If you do not specify WaitTimeSeconds in the request the queue attribute ReceiveMessageWaitTimeSeconds is used to determine how long to wait. |  | Integer
 | **redrivePolicy** (queue) | Specify the policy that send message to DeadLetter queue. See detail at Amazon docs. |  | String
+| **accessKey** (security) | Amazon AWS Access Key |  | String
+| **secretKey** (security) | Amazon AWS Secret Key |  | String
 |=======================================================================
 // endpoint options: END
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2e839f0c/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 b11e89d..723f349 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
@@ -27,13 +27,15 @@ public class SqsConfiguration {
     private String queueName;
     @UriParam
     private AmazonSQS amazonSQSClient;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String accessKey;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String secretKey;
+    @UriParam(defaultValue = "amazonaws.com")
+    private String amazonAWSHost = "amazonaws.com";
     @UriParam
     private String amazonSQSEndpoint;
-    @UriParam
+    @UriParam(secret = true)
     private String queueOwnerAWSAccountId;
     @UriParam
     private String region;
@@ -93,6 +95,17 @@ public class SqsConfiguration {
         return amazonSQSEndpoint;
     }
 
+    public String getAmazonAWSHost() {
+        return amazonAWSHost;
+    }
+
+    /**
+     * The hostname of the Amazon AWS cloud.
+     */
+    public void setAmazonAWSHost(String amazonAWSHost) {
+        this.amazonAWSHost = amazonAWSHost;
+    }
+
     public String getQueueName() {
         return queueName;
     }
@@ -355,6 +368,7 @@ public class SqsConfiguration {
     @Override
     public String toString() {
         return "SqsConfiguration[queueName=" + queueName
+            + ", amazonAWSHost=" + amazonAWSHost
             + ", amazonSQSClient=" + amazonSQSClient
             + ", accessKey=" + accessKey
             + ", secretKey=xxxxxxxxxxxxxxx"

http://git-wip-us.apache.org/repos/asf/camel/blob/2e839f0c/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 8601bb2..d1cc215 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
@@ -47,6 +47,7 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -125,7 +126,9 @@ public class SqsEndpoint extends ScheduledPollEndpoint implements HeaderFilterSt
         // 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/"
+            String host = configuration.getAmazonAWSHost();
+            host = FileUtil.stripTrailingSeparator(host);
+            queueUrl = "https://sqs." + configuration.getRegion() + "." + host + "/"
                 +  configuration.getQueueOwnerAWSAccountId() + "/" + configuration.getQueueName();
         } else if (configuration.getQueueOwnerAWSAccountId() != null) {
             GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest();
@@ -148,6 +151,7 @@ public class SqsEndpoint extends ScheduledPollEndpoint implements HeaderFilterSt
         if (queueUrl == null) {
             createQueue(client);
         } else {
+            LOG.debug("Using Amazon SQS queue url: {}", queueUrl);
             updateQueueAttributes(client);
         }
     }