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/12 09:46:20 UTC
[camel] 01/02: CAMEL-14690 - Camel-AWS2: Better logging when
checking client instance in the registry, SES
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 607b30085b6f68b23574c65f8e91aa0e38fea057
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Mar 12 10:45:20 2020 +0100
CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, SES
---
.../camel/component/aws2/ses/Ses2Component.java | 24 +++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index 8a7039a..0e5c576 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -24,6 +24,10 @@ import org.apache.camel.Endpoint;
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.ses.SesClient;
/**
@@ -32,6 +36,8 @@ import software.amazon.awssdk.services.ses.SesClient;
@Component("aws2-ses")
public class Ses2Component extends DefaultComponent {
+ private static final Logger LOG = LoggerFactory.getLogger(Ses2Component.class);
+
@Metadata
private Ses2Configuration configuration = new Ses2Configuration();
@@ -55,7 +61,7 @@ public class Ses2Component extends DefaultComponent {
configuration.setFrom(remaining);
Ses2Endpoint endpoint = new Ses2Endpoint(uri, this, configuration);
setProperties(endpoint, parameters);
- checkAndSetRegistryClient(configuration);
+ checkAndSetRegistryClient(configuration, endpoint);
if (configuration.getAmazonSESClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException("AmazonSESClient or accessKey and secretKey must be specified");
}
@@ -74,10 +80,18 @@ public class Ses2Component extends DefaultComponent {
this.configuration = configuration;
}
- private void checkAndSetRegistryClient(Ses2Configuration configuration) {
- Set<SesClient> clients = getCamelContext().getRegistry().findByType(SesClient.class);
- if (clients.size() == 1) {
- configuration.setAmazonSESClient(clients.stream().findFirst().get());
+ private void checkAndSetRegistryClient(Ses2Configuration configuration, Ses2Endpoint endpoint) {
+ if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonSESClient())) {
+ LOG.debug("Looking for an SesClient instance in the registry");
+ Set<SesClient> clients = getCamelContext().getRegistry().findByType(SesClient.class);
+ if (clients.size() == 1) {
+ LOG.debug("Found exactly one SesClient instance in the registry");
+ configuration.setAmazonSESClient(clients.stream().findFirst().get());
+ } else {
+ LOG.debug("No SesClient instance in the registry");
+ }
+ } else {
+ LOG.debug("SesClient instance is already set at endpoint level: skipping the check in the registry");
}
}
}