You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/05/30 12:20:59 UTC
(camel) 05/06: CAMEL-20798: Add endpoint service registry
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch sr
in repository https://gitbox.apache.org/repos/asf/camel.git
commit faaae4630a48c190394c4c55b0aeafe03fd6ba44
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu May 30 13:50:32 2024 +0200
CAMEL-20798: Add endpoint service registry
---
.../java/org/apache/camel/impl/console/ServiceDevConsole.java | 6 ++++++
.../apache/camel/api/management/mbean/CamelOpenMBeanTypes.java | 6 +++---
.../camel/management/mbean/ManagedEndpointServiceRegistry.java | 5 +++--
.../camel/dsl/jbang/core/commands/process/ListService.java | 10 ++++++++++
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/ServiceDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/ServiceDevConsole.java
index 3023cf71c47..2c0c89c082f 100644
--- a/core/camel-console/src/main/java/org/apache/camel/impl/console/ServiceDevConsole.java
+++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/ServiceDevConsole.java
@@ -48,6 +48,9 @@ public class ServiceDevConsole extends AbstractDevConsole {
sb.append(String.format("\n Protocol: %s", es.getServiceProtocol()));
sb.append(String.format("\n Service: %s", es.getServiceUrl()));
sb.append(String.format("\n Endpoint: %s", URISupport.sanitizeUri(es.getServiceUrl())));
+ if (es.getRouteId() != null) {
+ sb.append(String.format("\n Route Id: %s", es.getRouteId()));
+ }
sb.append(String.format("\n Total Messages: %d", es.getHits()));
}
sb.append("\n");
@@ -71,6 +74,9 @@ public class ServiceDevConsole extends AbstractDevConsole {
jo.put("protocol", es.getServiceProtocol());
jo.put("serviceUrl", es.getServiceUrl());
jo.put("endpointUri", es.getEndpointUri());
+ if (es.getRouteId() != null) {
+ jo.put("routeId", es.getRouteId());
+ }
jo.put("hits", es.getHits());
var map = es.getServiceMetadata();
if (map != null) {
diff --git a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
index 2d23e923fad..bcbd593836a 100644
--- a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
+++ b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
@@ -40,12 +40,12 @@ public final class CamelOpenMBeanTypes {
return new CompositeType(
"endpoints", "Endpoint Services",
new String[] {
- "component", "dir", "protocol", "serviceUrl", "metadata", "endpointUri", "hits" },
+ "component", "dir", "protocol", "serviceUrl", "metadata", "endpointUri", "routeId", "hits" },
new String[] {
- "Component", "Direction", "Protocol", "Service Url", "Metadata", "Endpoint Uri", "Hits" },
+ "Component", "Direction", "Protocol", "Service Url", "Metadata", "Endpoint Uri", "Route Id", "Hits" },
new OpenType[] {
SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING,
- SimpleType.STRING, SimpleType.LONG });
+ SimpleType.STRING, SimpleType.STRING, SimpleType.LONG });
}
public static TabularType listRestServicesTabularType() throws OpenDataException {
diff --git a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedEndpointServiceRegistry.java b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedEndpointServiceRegistry.java
index 9882e75375d..1ac68682d15 100644
--- a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedEndpointServiceRegistry.java
+++ b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedEndpointServiceRegistry.java
@@ -67,6 +67,7 @@ public class ManagedEndpointServiceRegistry extends ManagedService implements Ma
String metadata = null;
String endpointUri = entry.getEndpointUri();
long hits = entry.getHits();
+ String routeId = entry.getRouteId();
var m = entry.getServiceMetadata();
if (m != null) {
StringJoiner sj = new StringJoiner(" ");
@@ -77,9 +78,9 @@ public class ManagedEndpointServiceRegistry extends ManagedService implements Ma
CompositeData data = new CompositeDataSupport(
ct,
new String[] {
- "component", "dir", "protocol", "serviceUrl", "metadata", "endpointUri", "hits" },
+ "component", "dir", "protocol", "serviceUrl", "metadata", "endpointUri", "routeId", "hits" },
new Object[] {
- component, dir, protocol, serviceUrl, metadata, endpointUri, hits });
+ component, dir, protocol, serviceUrl, metadata, endpointUri, routeId, hits });
answer.put(data);
}
return answer;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListService.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListService.java
index 82942ed1ed7..bc6ac3663d3 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListService.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListService.java
@@ -99,6 +99,7 @@ public class ListService extends ProcessWatchCommand {
row.serviceUrl = jo.getString("serviceUrl");
row.endpointUri = jo.getString("endpointUri");
row.hits = jo.getLongOrDefault("hits", 0);
+ row.routeId = jo.getString("routeId");
row.metadata = jo.getMap("metadata");
rows.add(row);
}
@@ -121,6 +122,7 @@ public class ListService extends ProcessWatchCommand {
new Column().header("SERVICE").dataAlign(HorizontalAlign.LEFT).with(this::getService),
new Column().header("METADATA").visible(metadata).dataAlign(HorizontalAlign.LEFT).with(this::getMetadata),
new Column().header("TOTAL").dataAlign(HorizontalAlign.RIGHT).with(r -> "" + r.hits),
+ new Column().header("ID").dataAlign(HorizontalAlign.RIGHT).with(this::getRouteId),
new Column().header("ENDPOINT").visible(!wideUri).dataAlign(HorizontalAlign.LEFT)
.maxWidth(90, OverflowBehaviour.ELLIPSIS_RIGHT)
.with(this::getUri),
@@ -132,6 +134,13 @@ public class ListService extends ProcessWatchCommand {
return 0;
}
+ private String getRouteId(Row r) {
+ if (r.routeId != null) {
+ return r.routeId;
+ }
+ return "";
+ }
+
protected int sortRow(Row o1, Row o2) {
String s = sort;
int negate = 1;
@@ -191,6 +200,7 @@ public class ListService extends ProcessWatchCommand {
String serviceUrl;
String endpointUri;
long hits;
+ String routeId;
JsonObject metadata;
Row copy() {