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 2024/06/21 08:33:01 UTC

(camel) 01/09: CAMEL-20798: EndpointServiceLocation on components to make it possible to know which remote system Camel connects to to assist for monitoring and observability - Azure Eventhubs

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

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

commit e42e48d9cc92b96914c704f66461059fa4c99ca0
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Jun 21 09:26:13 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 - Azure Eventhubs
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../azure/eventhubs/EventHubsEndpoint.java         | 27 +++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java
index b6a2bfa840a..7804cc3755b 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java
+++ b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java
@@ -21,9 +21,13 @@ import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.spi.EndpointServiceLocation;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+import java.util.Map;
 
 /**
  * Send and receive events to/from Azure Event Hubs using AMQP protocol.
@@ -32,7 +36,7 @@ import org.apache.camel.support.DefaultEndpoint;
              syntax = "azure-eventhubs:namespace/eventHubName", category = {
                      Category.CLOUD, Category.MESSAGING },
              headersClass = EventHubsConstants.class)
-public class EventHubsEndpoint extends DefaultEndpoint {
+public class EventHubsEndpoint extends DefaultEndpoint implements EndpointServiceLocation {
 
     @UriParam
     private EventHubsConfiguration configuration;
@@ -66,4 +70,25 @@ public class EventHubsEndpoint extends DefaultEndpoint {
         this.configuration = configuration;
     }
 
+    @Override
+    public String getServiceUrl() {
+        if (ObjectHelper.isNotEmpty(configuration.getEventHubName())) {
+            return configuration.getEventHubName();
+        }
+        return null;
+    }
+
+    @Override
+    public String getServiceProtocol() {
+        return "eventhubs";
+    }
+
+    @Override
+    public Map<String, String> getServiceMetadata() {
+        if (configuration.getNamespace() != null) {
+            return Map.of("namespace", configuration.getNamespace());
+        }
+        return null;
+    }
+
 }