This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch filter-kamelet2 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7db463c170abc8ba450da2d9baca5a3e397206a8 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Feb 24 10:58:52 2024 +0100 CAMEL-18858: camel-core - Mark route as created by Kamelet so we know this, so we can filter out in tooling and whereelse (kamelet is a blackbox) --- .../component/kamelet/ManagedKameletRouteDisabledTest.java | 9 +-------- ...meletRouteTest.java => ManagedKameletRouteEnabledTest.java} | 10 +++++++++- .../src/main/java/org/apache/camel/spi/ManagementAgent.java | 4 ++-- .../org/apache/camel/management/DefaultManagementAgent.java | 2 +- .../modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc | 10 ++++++++++ docs/user-manual/modules/ROOT/pages/jmx.adoc | 8 +++++--- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteDisabledTest.java b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteDisabledTest.java index 908c93248d4..bfa26bd1990 100644 --- a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteDisabledTest.java +++ b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteDisabledTest.java @@ -23,7 +23,6 @@ import java.util.UUID; import javax.management.MBeanServer; import javax.management.ObjectName; -import org.apache.camel.CamelContext; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; @@ -46,13 +45,6 @@ public class ManagedKameletRouteDisabledTest extends CamelTestSupport { return context.getManagementStrategy().getManagementAgent().getMBeanServer(); } - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext context = super.createCamelContext(); - context.getManagementStrategy().getManagementAgent().setRegisterRoutesCreateByKamelet(false); - return context; - } - @Test public void testKameletRouteMBeanDisabled() throws Exception { String body = UUID.randomUUID().toString(); @@ -72,6 +64,7 @@ public class ManagedKameletRouteDisabledTest extends CamelTestSupport { ids.add(name); } assertTrue(ids.contains("direct")); + // is disabled by default assertFalse(ids.contains("kamelet")); } diff --git a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteTest.java b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteEnabledTest.java similarity index 88% rename from components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteTest.java rename to components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteEnabledTest.java index 5c7a676c545..81df1c2d597 100644 --- a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteTest.java +++ b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/ManagedKameletRouteEnabledTest.java @@ -23,6 +23,7 @@ import java.util.UUID; import javax.management.MBeanServer; import javax.management.ObjectName; +import org.apache.camel.CamelContext; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; @@ -33,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -public class ManagedKameletRouteTest extends CamelTestSupport { +public class ManagedKameletRouteEnabledTest extends CamelTestSupport { @Override protected boolean useJmx() { @@ -44,6 +45,13 @@ public class ManagedKameletRouteTest extends CamelTestSupport { return context.getManagementStrategy().getManagementAgent().getMBeanServer(); } + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + context.getManagementStrategy().getManagementAgent().setRegisterRoutesCreateByKamelet(true); + return context; + } + @Test public void testKameletRouteMBean() throws Exception { String body = UUID.randomUUID().toString(); diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java index 01b1257e3d9..214d5ddf4d6 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java @@ -202,14 +202,14 @@ public interface ManagementAgent extends Service { /** * Whether to register mbeans for routes created by a Kamelet * <p/> - * This option is default <tt>true</tt>. + * This option is default <tt>false</tt>. */ Boolean getRegisterRoutesCreateByKamelet(); /** * Whether to register mbeans for routes created by a Kamelet * <p/> - * This option is default <tt>true</tt>. + * This option is default <tt>false</tt>. */ void setRegisterRoutesCreateByKamelet(Boolean registerRoutesCreateByKamelet); diff --git a/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementAgent.java b/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementAgent.java index beef93e89f8..fb6c3ef83e0 100644 --- a/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementAgent.java +++ b/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementAgent.java @@ -69,7 +69,7 @@ public class DefaultManagementAgent extends ServiceSupport implements Management private Boolean endpointRuntimeStatisticsEnabled; private Boolean registerAlways = false; private Boolean registerNewRoutes = true; - private Boolean registerRoutesCreateByKamelet = true; + private Boolean registerRoutesCreateByKamelet = false; private Boolean registerRoutesCreateByTemplate = true; private Boolean mask = true; private Boolean includeHostName = false; diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc index d63ab7d76bd..a8096295f85 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc @@ -26,3 +26,13 @@ After: ---- String uri = exchange.getProperty(Exchange.INTERCEPTED_ENDPOINT, String.class); ---- + +=== camel-kamelet + +Routes created by Kamelets are no longer registered as JMX MBeans to avoid cluttering up with unwanted MBeans, as a Kamelet +is intended to act like a Camel component, despite its implementation is Camel routes. This means that the number of routes +listed from JMX etc will no longer include Kamelet routes. + + +The old behaviour can be enabled by setting `registerRoutesCreateByKamelet=true` +on the `ManagementAgent` object. See more in the xref:jmx.adoc[JMX] documentation. diff --git a/docs/user-manual/modules/ROOT/pages/jmx.adoc b/docs/user-manual/modules/ROOT/pages/jmx.adoc index e13a85e1b83..705566d71b0 100644 --- a/docs/user-manual/modules/ROOT/pages/jmx.adoc +++ b/docs/user-manual/modules/ROOT/pages/jmx.adoc @@ -146,7 +146,7 @@ Camel provides the following settings to control when to register mbeans. CamelContext has been started will also register MBeans from that given route. -|`registerRoutesCreateByKamelet` |`true` |If enabled then adding routes created by Kamelet will also register MBeans from that given route. +|`registerRoutesCreateByKamelet` |`false` |If enabled then adding routes created by Kamelet will also register MBeans from that given route. |`registerRoutesCreateByTemplate` |`true` |If enabled then adding routes created by route template (not Kamelet, see option above) will also register MBeans from that given route. @@ -159,8 +159,10 @@ example, if you are adding and removing temporary routes that do not require management. In *Camel 4.5* onwards there are additional options to configure whether routes created from route templates or Kamelets -should be registered as MBeans or not. Disabling this allows to not clutter up with many MBeans for Kamelets or route -templates that may not be needed for management and monitoring. +should be registered as MBeans or not. By default, Kamelets are now disabled with the intention to regard a Kamelet +as a component, instead of a set of additional routes and processors MBeans that is essentially not needed for management +and monitoring. The option `registerRoutesCreateByKamelet` can be set to `true` to enable MBeans which is how Camel 4.4 or +older behaves. On the other hand routes created from route templates (not Kamelets) are default enabled. CAUTION: However, be cautious when using the `registerAlways` option in conjunction with dynamic EIP patterns, such as the xref:components:eips:recipientList-eip.adoc[Recipient List],