camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [8/9] camel git commit: CAMEL-11736 - Camel-AWS: Use regional client instead of define region for single operation - AWS SQS
Date Fri, 01 Sep 2017 11:45:24 GMT
CAMEL-11736 - Camel-AWS: Use regional client instead of define region for single operation
- AWS SQS


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

Branch: refs/heads/master
Commit: 974ff8f90c9c9a42c339c56eefc249a59a200af7
Parents: fadf980
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Fri Sep 1 13:32:32 2017 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Sep 1 13:32:32 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/component/aws/sqs/SqsEndpoint.java  | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/974ff8f9/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 e4806eb..8ba00c4 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
@@ -24,6 +24,7 @@ import com.amazonaws.auth.AWSCredentials;
 import com.amazonaws.auth.AWSCredentialsProvider;
 import com.amazonaws.auth.AWSStaticCredentialsProvider;
 import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
 import com.amazonaws.services.sqs.AmazonSQS;
 import com.amazonaws.services.sqs.AmazonSQSClient;
 import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
@@ -277,6 +278,7 @@ public class SqsEndpoint extends ScheduledPollEndpoint implements HeaderFilterSt
      */
     AmazonSQS createClient() {
         AmazonSQS client = null;
+        AmazonSQSClientBuilder clientBuilder = null;
         ClientConfiguration clientConfiguration = null;
         boolean isClientConfigFound = false;
         if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort()))
{
@@ -289,17 +291,22 @@ public class SqsEndpoint extends ScheduledPollEndpoint implements HeaderFilterSt
             AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(),
configuration.getSecretKey());
             AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
             if (isClientConfigFound) {
-                client = AmazonSQSClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider).build();
+                clientBuilder = AmazonSQSClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider);
             } else {
-                client = AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider).build();
+                clientBuilder = AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider);
             }
         } else {
             if (isClientConfigFound) {
-                client = AmazonSQSClientBuilder.standard().build();
+                clientBuilder = AmazonSQSClientBuilder.standard();
             } else {
-                client = AmazonSQSClientBuilder.standard().withClientConfiguration(clientConfiguration).build();
+                clientBuilder = AmazonSQSClientBuilder.standard().withClientConfiguration(clientConfiguration);
             }
         }
+        if (ObjectHelper.isNotEmpty(configuration.getAmazonSQSEndpoint()) && ObjectHelper.isNotEmpty(configuration.getRegion()))
{
+            EndpointConfiguration endpointConfiguration = new EndpointConfiguration(configuration.getAmazonSQSEndpoint(),
configuration.getRegion());
+            clientBuilder = clientBuilder.withEndpointConfiguration(endpointConfiguration);
+        }
+        client = clientBuilder.build();
         return client;
     }
 


Mime
View raw message