This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch CAMEL-20798-gcp
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9d631b7105e347b2abf59706c88a2796ad1ced09
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Fri Jun 28 11:04:01 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
    
    Signed-off-by: Andrea Cosentino <anco...@gmail.com>
---
 .../google/pubsub/GooglePubsubEndpoint.java        | 30 ++++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git 
a/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java
 
b/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java
index e4298e3edcf..e8ec322336a 100644
--- 
a/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java
+++ 
b/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.google.pubsub;
 
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 
 import org.apache.camel.Category;
@@ -26,10 +27,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import 
org.apache.camel.component.google.pubsub.serializer.DefaultGooglePubsubSerializer;
 import 
org.apache.camel.component.google.pubsub.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;
@@ -43,7 +41,7 @@ import org.slf4j.LoggerFactory;
 @UriEndpoint(firstVersion = "2.19.0", scheme = "google-pubsub", title = 
"Google Pubsub",
              syntax = "google-pubsub:projectId:destinationName", category = { 
Category.CLOUD, Category.MESSAGING },
              headersClass = GooglePubsubConstants.class)
-public class GooglePubsubEndpoint extends DefaultEndpoint {
+public class GooglePubsubEndpoint extends DefaultEndpoint implements 
EndpointServiceLocation {
 
     private Logger log;
 
@@ -261,4 +259,26 @@ public class GooglePubsubEndpoint extends DefaultEndpoint {
     public void setPubsubEndpoint(String pubsubEndpoint) {
         this.pubsubEndpoint = pubsubEndpoint;
     }
+
+    @Override
+    public String getServiceUrl() {
+        if (ObjectHelper.isNotEmpty(getPubsubEndpoint())) {
+            return getServiceProtocol() + ":" + getPubsubEndpoint();
+        }
+        return null;
+    }
+
+    @Override
+    public String getServiceProtocol() {
+        return "pubsub";
+    }
+
+    @Override
+    public Map<String, String> getServiceMetadata() {
+        if (getDestinationName() != null) {
+            return Map.of("destinationName", getDestinationName());
+            );
+        }
+        return null;
+    }
 }

Reply via email to