This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.14.x by this push:
new 0aa23c6a6f27 CAMEL-22828: camel-main - Register runtime endpoint
registry MBean if enabled.
0aa23c6a6f27 is described below
commit 0aa23c6a6f278cb1241ca323385b369ade8e48ec
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jan 9 21:20:07 2026 +0100
CAMEL-22828: camel-main - Register runtime endpoint registry MBean if
enabled.
---
.../engine/DefaultRuntimeEndpointRegistry.java | 3 +-
.../ManagedRuntimeEndpointRegistryTest.java | 93 ++++++++++++++++++++++
2 files changed, 94 insertions(+), 2 deletions(-)
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
index f81b1f14d612..e49217d5ec13 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
@@ -25,7 +25,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.camel.Endpoint;
-import org.apache.camel.NonManagedService;
import org.apache.camel.spi.CamelEvent;
import org.apache.camel.spi.CamelEvent.ExchangeCreatedEvent;
import org.apache.camel.spi.CamelEvent.ExchangeSendingEvent;
@@ -42,7 +41,7 @@ import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport
implements RuntimeEndpointRegistry, NonManagedService {
+public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport
implements RuntimeEndpointRegistry {
private static final Logger LOG =
LoggerFactory.getLogger(DefaultRuntimeEndpointRegistry.class);
diff --git
a/core/camel-management/src/test/java/org/apache/camel/management/ManagedRuntimeEndpointRegistryTest.java
b/core/camel-management/src/test/java/org/apache/camel/management/ManagedRuntimeEndpointRegistryTest.java
new file mode 100644
index 000000000000..d9e0d8091e13
--- /dev/null
+++
b/core/camel-management/src/test/java/org/apache/camel/management/ManagedRuntimeEndpointRegistryTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.management;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.openmbean.TabularData;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ManagementStatisticsLevel;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+@DisabledOnOs(OS.AIX)
+public class ManagedRuntimeEndpointRegistryTest extends ManagementTestSupport {
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+
context.getManagementStrategy().getManagementAgent().setEndpointRuntimeStatisticsEnabled(true);
+
context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
+ return context;
+ }
+
+ @Test
+ public void testManageRuntimeEndpointRegistry() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+
+ // to create a dynamic endpoint
+ template.sendBody("log:foo", "Hello World");
+
+ // get the stats for the route
+ MBeanServer mbeanServer = getMBeanServer();
+ Set<ObjectName> set = mbeanServer.queryNames(new
ObjectName("*:type=services,*"), null);
+ List<ObjectName> list = new ArrayList<>(set);
+ ObjectName on = null;
+ for (ObjectName name : list) {
+ if
(name.getCanonicalName().contains("DefaultRuntimeEndpointRegistry")) {
+ on = name;
+ break;
+ }
+ }
+
+ assertNotNull(on, "Should have found RuntimeEndpointRegistry");
+
+ Integer max = (Integer) mbeanServer.getAttribute(on, "Limit");
+ assertEquals(1000, max.intValue());
+
+ Integer current = (Integer) mbeanServer.getAttribute(on, "Size");
+ assertEquals(2, current.intValue());
+
+ TabularData data = (TabularData) mbeanServer.invoke(on,
"endpointStatistics", null, null);
+ assertEquals(2, data.size());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start").to("mock:result");
+ }
+ };
+ }
+
+}