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 2020/03/11 10:40:02 UTC
[camel] 02/04: CAMEL-14690 - Camel-AWS2: Better logging when
checking client instance in the registry, DynamoDBStreams
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 40c5139b29332acf4faf1dc23df5fd6a52c3676b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 11 11:38:16 2020 +0100
CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, DynamoDBStreams
---
.../aws2/ddbstream/Ddb2StreamComponent.java | 26 +++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamComponent.java b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamComponent.java
index 5c20951..0c48318 100644
--- a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamComponent.java
+++ b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamComponent.java
@@ -21,13 +21,21 @@ import java.util.Set;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
+import org.apache.camel.component.aws2.ddb.Ddb2Component;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient;
@Component("aws2-ddbstream")
public class Ddb2StreamComponent extends DefaultComponent {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Ddb2StreamComponent.class);
@Metadata
private Ddb2StreamConfiguration configuration = new Ddb2StreamConfiguration();
@@ -52,7 +60,7 @@ public class Ddb2StreamComponent extends DefaultComponent {
configuration.setTableName(remaining);
Ddb2StreamEndpoint endpoint = new Ddb2StreamEndpoint(uri, configuration, this);
setProperties(endpoint, parameters);
- checkAndSetRegistryClient(configuration);
+ checkAndSetRegistryClient(configuration, endpoint);
if (configuration.getAmazonDynamoDbStreamsClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException("amazonDDBStreamsClient or accessKey and secretKey must be specified");
}
@@ -70,10 +78,18 @@ public class Ddb2StreamComponent extends DefaultComponent {
this.configuration = configuration;
}
- private void checkAndSetRegistryClient(Ddb2StreamConfiguration configuration) {
- Set<DynamoDbStreamsClient> clients = getCamelContext().getRegistry().findByType(DynamoDbStreamsClient.class);
- if (clients.size() == 1) {
- configuration.setAmazonDynamoDbStreamsClient(clients.stream().findFirst().get());
+ private void checkAndSetRegistryClient(Ddb2StreamConfiguration configuration, Ddb2StreamEndpoint endpoint) {
+ if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonDynamoDbStreamsClient())) {
+ LOG.debug("Looking for an DynamoDbStreamsClient instance in the registry");
+ Set<DynamoDbStreamsClient> clients = getCamelContext().getRegistry().findByType(DynamoDbStreamsClient.class);
+ if (clients.size() == 1) {
+ LOG.debug("Found exactly one DynamoDbStreamsClient instance in the registry");
+ configuration.setAmazonDynamoDbStreamsClient(clients.stream().findFirst().get());
+ } else {
+ LOG.debug("No DynamoDbStreamsClient instance in the registry");
+ }
+ } else {
+ LOG.debug("DynamoDbStreamsClient instance is already set at endpoint level: skipping the check in the registry");
}
}
}