You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/09/01 11:45:21 UTC
[5/9] camel git commit: CAMEL-11736 - Camel-AWS: Use regional client
instead of define region for single operation - AWS SDB
CAMEL-11736 - Camel-AWS: Use regional client instead of define region for single operation - AWS SDB
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fc16ce16
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc16ce16
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc16ce16
Branch: refs/heads/master
Commit: fc16ce1670434290facd9264c1052b31d3827792
Parents: 5fed8b2
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri Sep 1 12:36:37 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri Sep 1 12:36:37 2017 +0200
----------------------------------------------------------------------
.../src/main/docs/aws-sdb-component.adoc | 7 ++++---
.../component/aws/sdb/SdbConfiguration.java | 17 +++++++++++++++--
.../camel/component/aws/sdb/SdbEndpoint.java | 19 +++++++++++--------
3 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fc16ce16/components/camel-aws/src/main/docs/aws-sdb-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/docs/aws-sdb-component.adoc b/components/camel-aws/src/main/docs/aws-sdb-component.adoc
index 36635b7..f133310 100644
--- a/components/camel-aws/src/main/docs/aws-sdb-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-sdb-component.adoc
@@ -46,7 +46,7 @@ with the following path and query parameters:
| **domainName** | *Required* The name of the domain currently worked with. | | String
|=======================================================================
-#### Query Parameters (10 parameters):
+#### Query Parameters (11 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|=======================================================================
@@ -57,8 +57,9 @@ with the following path and query parameters:
| **consistentRead** (producer) | Determines whether or not strong consistency should be enforced when data is read. | false | boolean
| **maxNumberOfDomains** (producer) | The maximum number of domain names you want returned. The range is 1 to 100. | | Integer
| **operation** (producer) | Operation to perform | PutAttributes | SdbOperations
-| **proxyHost** (producer) | To define a proxy host when instantiating the SQS client | | String
-| **proxyPort** (producer) | To define a proxy port when instantiating the SQS client | | Integer
+| **proxyHost** (producer) | To define a proxy host when instantiating the SDB client | | String
+| **proxyPort** (producer) | To define a proxy port when instantiating the SDB client | | Integer
+| **region** (producer) | The region in which SDB client needs to work | | String
| **secretKey** (producer) | Amazon AWS Secret Key | | String
| **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean
|=======================================================================
http://git-wip-us.apache.org/repos/asf/camel/blob/fc16ce16/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbConfiguration.java
index 30019ff..5686f7f 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbConfiguration.java
@@ -46,6 +46,8 @@ public class SdbConfiguration {
private String proxyHost;
@UriParam
private Integer proxyPort;
+ @UriParam
+ private String region;
/**
* The region with which the AWS-SDB client wants to work with.
@@ -136,7 +138,7 @@ public class SdbConfiguration {
}
/**
- * To define a proxy host when instantiating the SQS client
+ * To define a proxy host when instantiating the SDB client
*/
public String getProxyHost() {
return proxyHost;
@@ -147,7 +149,7 @@ public class SdbConfiguration {
}
/**
- * To define a proxy port when instantiating the SQS client
+ * To define a proxy port when instantiating the SDB client
*/
public Integer getProxyPort() {
return proxyPort;
@@ -156,4 +158,15 @@ public class SdbConfiguration {
public void setProxyPort(Integer proxyPort) {
this.proxyPort = proxyPort;
}
+
+ /**
+ * The region in which SDB client needs to work
+ */
+ public String getRegion() {
+ return region;
+ }
+
+ public void setRegion(String region) {
+ this.region = region;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/fc16ce16/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbEndpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbEndpoint.java
index 812cf0c..c2ace82 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbEndpoint.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbEndpoint.java
@@ -21,8 +21,8 @@ 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.simpledb.AmazonSimpleDB;
-import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
import com.amazonaws.services.simpledb.AmazonSimpleDBClientBuilder;
import com.amazonaws.services.simpledb.model.CreateDomainRequest;
import com.amazonaws.services.simpledb.model.DomainMetadataRequest;
@@ -81,9 +81,6 @@ public class SdbEndpoint extends ScheduledPollEndpoint {
super.doStart();
sdbClient = configuration.getAmazonSDBClient() != null ? configuration.getAmazonSDBClient() : createSdbClient();
- if (ObjectHelper.isNotEmpty(configuration.getAmazonSdbEndpoint())) {
- sdbClient.setEndpoint(configuration.getAmazonSdbEndpoint());
- }
String domainName = getConfiguration().getDomainName();
LOG.trace("Querying whether domain [{}] already exists...", domainName);
@@ -110,6 +107,7 @@ public class SdbEndpoint extends ScheduledPollEndpoint {
AmazonSimpleDB createSdbClient() {
AmazonSimpleDB client = null;
+ AmazonSimpleDBClientBuilder clientBuilder = null;
ClientConfiguration clientConfiguration = null;
boolean isClientConfigFound = false;
if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
@@ -122,17 +120,22 @@ public class SdbEndpoint extends ScheduledPollEndpoint {
AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
if (isClientConfigFound) {
- client = AmazonSimpleDBClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider).build();
+ clientBuilder = AmazonSimpleDBClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider);
} else {
- client = AmazonSimpleDBClientBuilder.standard().withCredentials(credentialsProvider).build();
+ clientBuilder = AmazonSimpleDBClientBuilder.standard().withCredentials(credentialsProvider);
}
} else {
if (isClientConfigFound) {
- client = AmazonSimpleDBClientBuilder.standard().build();
+ clientBuilder = AmazonSimpleDBClientBuilder.standard();
} else {
- client = AmazonSimpleDBClientBuilder.standard().withClientConfiguration(clientConfiguration).build();
+ clientBuilder = AmazonSimpleDBClientBuilder.standard().withClientConfiguration(clientConfiguration);
}
}
+ if (ObjectHelper.isNotEmpty(configuration.getAmazonSdbEndpoint()) && ObjectHelper.isNotEmpty(configuration.getRegion())) {
+ EndpointConfiguration endpointConfiguration = new EndpointConfiguration(configuration.getAmazonSdbEndpoint(), configuration.getRegion());
+ clientBuilder = clientBuilder.withEndpointConfiguration(endpointConfiguration);
+ }
+ client = clientBuilder.build();
return client;
}
}