This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch CAMEL-20798-AWS-complete in repository https://gitbox.apache.org/repos/asf/camel.git
commit fb8b03d9a8165376a9c6b85429baa37464e9ad63 Author: Andrea Cosentino <[email protected]> AuthorDate: Tue Jun 18 10:39:58 2024 +0200 CAMEL-20798: EndpointServiceLocation on components to make it possible to know which remote system Camel connects to to assist for monitoring and observability - AWS SNS Signed-off-by: Andrea Cosentino <[email protected]> --- .../camel/component/aws2/sns/Sns2Endpoint.java | 38 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java index d2ec93a3f1a..6331b2215b1 100644 --- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java +++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java @@ -27,12 +27,7 @@ import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; import org.apache.camel.component.aws2.sns.client.Sns2ClientFactory; -import org.apache.camel.spi.HeaderFilterStrategy; -import org.apache.camel.spi.HeaderFilterStrategyAware; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.UriEndpoint; -import org.apache.camel.spi.UriParam; -import org.apache.camel.spi.UriPath; +import org.apache.camel.spi.*; import org.apache.camel.support.DefaultEndpoint; import org.apache.camel.support.ResourceHelper; import org.apache.camel.util.ObjectHelper; @@ -56,7 +51,7 @@ import software.amazon.awssdk.services.sns.model.Topic; @UriEndpoint(firstVersion = "3.1.0", scheme = "aws2-sns", title = "AWS Simple Notification System (SNS)", syntax = "aws2-sns:topicNameOrArn", producerOnly = true, category = { Category.CLOUD, Category.MESSAGING, Category.MOBILE }, headersClass = Sns2Constants.class) -public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrategyAware { +public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrategyAware, EndpointServiceLocation { private static final Logger LOG = LoggerFactory.getLogger(Sns2Endpoint.class); @@ -213,4 +208,33 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg public SnsClient getSNSClient() { return snsClient; } + + @Override + public String getServiceUrl() { + if (!configuration.isOverrideEndpoint()) { + if (ObjectHelper.isNotEmpty(configuration.getRegion())) { + return configuration.getRegion(); + } + } else if (ObjectHelper.isNotEmpty(configuration.getUriEndpointOverride())) { + return configuration.getUriEndpointOverride(); + } + return null; + } + + @Override + public String getServiceProtocol() { + return "kinesis"; + } + + @Override + public Map<String, String> getServiceMetadata() { + HashMap<String, String> metadata = new HashMap<>(); + if (configuration.getQueueArn() != null) { + metadata.put("queueArn", configuration.getQueueArn()); + } + if (configuration.getTopicArn() != null) { + metadata.put("topicArn", configuration.getTopicArn()); + } + return metadata; + } }
