This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 173009ab892008272f8a28cefec0109ebb867995
Author: Dani Rey <dani.rey...@gmail.com>
AuthorDate: Wed May 2 16:33:50 2018 +0200

    Add url parameter to configure the queueUrl of an SqsEndpoint
---
 .../camel-aws/src/main/docs/aws-sqs-component.adoc |  3 +-
 .../camel/component/aws/sqs/SqsConfiguration.java  | 13 +++++++
 .../camel/component/aws/sqs/SqsEndpoint.java       | 44 +++++++++++-----------
 3 files changed, 38 insertions(+), 22 deletions(-)

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 5af3f9f..72bc438 100644
--- a/components/camel-aws/src/main/docs/aws-sqs-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-sqs-component.adoc
@@ -68,7 +68,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (46 parameters):
+==== Query Parameters (47 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -78,6 +78,7 @@ with the following path and query parameters:
 | *amazonSQSClient* (common) | To use the AmazonSQS as client |  | AmazonSQS
 | *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
+| *queueUrl* (common) | To define the queueUrl explicitly. All other 
parameters which would influence the queueUrl are ignored. |  | String
 | *region* (common) | Specify the queue region which could be used with 
queueOwnerAWSAccountId to build the service URL. |  | 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
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 d052976..daa098b 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
@@ -63,6 +63,8 @@ public class SqsConfiguration implements Cloneable {
     private boolean extendMessageVisibility;
     @UriParam(label = "consumer", defaultValue = "1")
     private int concurrentConsumers = 1;
+       @UriParam
+    private String queueUrl;
 
     // producer properties
     @UriParam(label = "producer")
@@ -345,6 +347,17 @@ public class SqsConfiguration implements Cloneable {
     public void setConcurrentConsumers(int concurrentConsumers) {
         this.concurrentConsumers = concurrentConsumers;
     }
+       
+       /**
+     *  To define the queueUrl explicitly. All other parameters, which would 
influence the queueUrl, are ignored.
+     */
+    public String getQueueUrl() {
+        return queueUrl;
+    }
+
+    public void setQueueUrl(String queueUrl) {
+        this.queueUrl = queueUrl;
+    }
 
     /**
      * To define a proxy host when instantiating the SQS client
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 1ab049b..91daa2c 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
@@ -121,28 +121,30 @@ public class SqsEndpoint extends ScheduledPollEndpoint 
implements HeaderFilterSt
             headerFilterStrategy = new SqsHeaderFilterStrategy();
         }
 
-        // 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) {
-            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();
-            getQueueUrlRequest.setQueueName(configuration.getQueueName());
-            
getQueueUrlRequest.setQueueOwnerAWSAccountId(configuration.getQueueOwnerAWSAccountId());
-            GetQueueUrlResult getQueueUrlResult = 
client.getQueueUrl(getQueueUrlRequest);
-            queueUrl = getQueueUrlResult.getQueueUrl();
+        if (configuration.getQueueUrl() != null) {
+            queueUrl = configuration.getQueueUrl();
         } else {
-            // check whether the queue already exists
-            ListQueuesResult listQueuesResult = client.listQueues();
-            for (String url : listQueuesResult.getQueueUrls()) {
-                if (url.endsWith("/" + configuration.getQueueName())) {
-                    queueUrl = url;
-                    LOG.trace("Queue available at '{}'.", queueUrl);
-                    break;
-                }
+            // 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());
+                GetQueueUrlResult getQueueUrlResult = 
client.getQueueUrl(getQueueUrlRequest);
+                queueUrl = getQueueUrlResult.getQueueUrl();
+            } else {
+                // check whether the queue already exists
+                ListQueuesResult listQueuesResult = client.listQueues();
+                for (String url : listQueuesResult.getQueueUrls()) {
+                    if (url.endsWith("/" + configuration.getQueueName())) {
+                        queueUrl = url;
+                        LOG.trace("Queue available at '{}'.", queueUrl);
+                        break;
+                    }
+                               }
             }
         }
 

-- 
To stop receiving notification emails like this one, please contact
acosent...@apache.org.

Reply via email to