This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit e5eba92cc38db732281ab21c4762c703b6b77245 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Fri Jun 28 11:05:34 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 - Google Pubsub Lite Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../pubsublite/GooglePubsubLiteEndpoint.java | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/components/camel-google/camel-google-pubsub-lite/src/main/java/org/apache/camel/component/google/pubsublite/GooglePubsubLiteEndpoint.java b/components/camel-google/camel-google-pubsub-lite/src/main/java/org/apache/camel/component/google/pubsublite/GooglePubsubLiteEndpoint.java index 4889e60f875..d6d092f4d48 100644 --- a/components/camel-google/camel-google-pubsub-lite/src/main/java/org/apache/camel/component/google/pubsublite/GooglePubsubLiteEndpoint.java +++ b/components/camel-google/camel-google-pubsub-lite/src/main/java/org/apache/camel/component/google/pubsublite/GooglePubsubLiteEndpoint.java @@ -16,15 +16,13 @@ */ package org.apache.camel.component.google.pubsublite; +import java.util.Map; import java.util.concurrent.ExecutorService; import org.apache.camel.*; import org.apache.camel.component.google.pubsublite.serializer.DefaultGooglePubsubSerializer; import org.apache.camel.component.google.pubsublite.serializer.GooglePubsubSerializer; -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.util.ObjectHelper; import org.slf4j.Logger; @@ -39,7 +37,7 @@ import org.slf4j.LoggerFactory; syntax = "google-pubsub-lite:projectId:location:destinationName", category = { Category.CLOUD, Category.MESSAGING }, headersClass = GooglePubsubLiteConstants.class) -public class GooglePubsubLiteEndpoint extends DefaultEndpoint { +public class GooglePubsubLiteEndpoint extends DefaultEndpoint implements EndpointServiceLocation { private Logger log; @@ -230,4 +228,25 @@ public class GooglePubsubLiteEndpoint extends DefaultEndpoint { public void setLocation(String location) { this.location = location; } + + @Override + public String getServiceUrl() { + if (ObjectHelper.isNotEmpty(getPubsubEndpoint())) { + return getServiceProtocol() + ":" + getPubsubEndpoint(); + } + return null; + } + + @Override + public String getServiceProtocol() { + return "pubsub-lite"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (getDestinationName() != null) { + return Map.of("destinationName", getDestinationName()); + } + return null; + } }