From b954402272ddcfbb45dc1495520f920e70cc041c Mon Sep 17 00:00:00 2001 From: Colm O hEigeartaigh Date: Mon, 30 Mar 2020 13:16:21 +0100 Subject: [PATCH] CAMEL-14811 - Remove JMX Connector configuration --- .../camel/spring/JMXAgentPropertiesTest.java | 9 +- .../org/apache/camel/spring/JMXAgentTest.java | 70 ------- .../org/apache/camel/spring/jmxConfig.xml | 43 ----- .../camel/spring/jmxConfigUsingProperties.xml | 3 +- .../org/apache/camel/spi/ManagementAgent.java | 72 +------ .../org/apache/camel/core/xml/jmxAgent.json | 4 - .../xml/AbstractCamelContextFactoryBean.java | 12 -- .../core/xml/CamelJMXAgentDefinition.java | 64 ------- ...MainConfigurationPropertiesConfigurer.java | 2 - .../camel-main-configuration-metadata.json | 1 - .../main/DefaultConfigurationConfigurer.java | 1 - .../main/DefaultConfigurationProperties.java | 24 --- .../api/management/JmxSystemPropertyKeys.java | 12 -- .../management/DefaultManagementAgent.java | 180 +----------------- .../DefaultManagementAgentMockTest.java | 2 - .../JmxInstrumentationUsingDefaultsTest.java | 2 - .../JmxInstrumentationWithConnectorTest.java | 139 -------------- .../management/ManagedComponentTest.java | 1 - .../ManagedRouteWithOnExceptionTest.java | 16 -- .../management/ManagedServiceUrlPathTest.java | 106 ----------- .../management/ManagementTestSupport.java | 18 -- .../ROOT/pages/influxdb-component.adoc | 3 +- .../modules/ROOT/pages/nats-component.adoc | 5 +- docs/user-manual/modules/ROOT/pages/jmx.adoc | 18 +- .../maven/packaging/MyConfiguration.java | 13 -- 25 files changed, 29 insertions(+), 791 deletions(-) delete mode 100644 components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java delete mode 100644 components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml delete mode 100644 core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java delete mode 100644 core/camel-management/src/test/java/org/apache/camel/management/ManagedServiceUrlPathTest.java diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentPropertiesTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentPropertiesTest.java index bb9693a71b785..cceb142fc1a01 100644 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentPropertiesTest.java +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentPropertiesTest.java @@ -25,12 +25,7 @@ /** * Test that verifies JMX properties can be configured via Spring. */ -public class JMXAgentPropertiesTest extends JMXAgentTest { - - @Override - protected int getPort() { - return 20009; - } +public class JMXAgentPropertiesTest extends DefaultJMXAgentTest { @Override protected AbstractXmlApplicationContext createApplicationContext() { @@ -45,4 +40,4 @@ public void testEnableUseHostIPAddress() throws Exception { assertTrue(agent.getUseHostIPAddress()); } -} \ No newline at end of file +} diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java deleted file mode 100644 index 32ea9fd6274d5..0000000000000 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/JMXAgentTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.spring; - -import javax.management.MBeanServerConnection; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; - -import org.junit.After; -import org.springframework.context.support.AbstractXmlApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * Test that verifies JMX properties can be configured via Spring. - */ -public class JMXAgentTest extends DefaultJMXAgentTest { - - protected final String jmxServiceUrl = "service:jmx:rmi:///jndi/rmi://localhost:" + getPort() + "/jmxrmi/camel"; - protected JMXConnector clientConnector; - - protected int getPort() { - return 20008; - } - - @Override - @After - public void tearDown() throws Exception { - if (clientConnector != null) { - try { - clientConnector.close(); - } catch (Exception e) { - // ignore - } - clientConnector = null; - } - super.tearDown(); - } - - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/camel/spring/jmxConfig.xml"); - } - - @Override - protected MBeanServerConnection getMBeanConnection() throws Exception { - if (mbsc == null) { - if (clientConnector == null) { - clientConnector = JMXConnectorFactory.connect(new JMXServiceURL(jmxServiceUrl), null); - } - mbsc = clientConnector.getMBeanServerConnection(); - } - return mbsc; - } - -} diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml deleted file mode 100644 index 0ffda39ec280c..0000000000000 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfigUsingProperties.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfigUsingProperties.xml index 0f7c73419ac1a..67d900df2a921 100644 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfigUsingProperties.xml +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfigUsingProperties.xml @@ -29,9 +29,8 @@ - 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 bca5417e40739..8be5a92ed4be7 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 @@ -29,7 +29,7 @@ public interface ManagementAgent extends Service { /** - * Registers object with management infrastructure with a specific name. Object must be annotated or + * Registers object with management infrastructure with a specific name. Object must be annotated or * implement standard MBean interface. * * @param obj the object to register @@ -37,9 +37,9 @@ public interface ManagementAgent extends Service { * @throws JMException is thrown if the registration failed */ void register(Object obj, ObjectName name) throws JMException; - + /** - * Registers object with management infrastructure with a specific name. Object must be annotated or + * Registers object with management infrastructure with a specific name. Object must be annotated or * implement standard MBean interface. * * @param obj the object to register @@ -49,7 +49,7 @@ public interface ManagementAgent extends Service { * @throws JMException is thrown if the registration failed */ void register(Object obj, ObjectName name, boolean forceRegistration) throws JMException; - + /** * Unregisters object based upon registered name * @@ -80,7 +80,7 @@ public interface ManagementAgent extends Service { *

* Notice: If the JMXEnabled configuration is not set to true, * this method will return null. - * + * * @return the MBeanServer */ MBeanServer getMBeanServer(); @@ -96,39 +96,11 @@ public interface ManagementAgent extends Service { * Get domain name for Camel MBeans. *

* Notice: That this can be different that the default domain name of the MBean Server. - * + * * @return domain name */ String getMBeanObjectDomainName(); - /** - * Sets the port used by {@link java.rmi.registry.LocateRegistry}. - * - * @param port the port - */ - void setRegistryPort(Integer port); - - /** - * Gets the port used by {@link java.rmi.registry.LocateRegistry}. - * - * @return the port - */ - Integer getRegistryPort(); - - /** - * Sets the port clients must use to connect - * - * @param port the port - */ - void setConnectorPort(Integer port); - - /** - * Gets the port clients must use to connect - * - * @return the port - */ - Integer getConnectorPort(); - /** * Sets the default domain on the MBean server * @@ -150,34 +122,6 @@ public interface ManagementAgent extends Service { */ void setMBeanObjectDomainName(String domainName); - /** - * Sets the service url - * - * @param url the service url - */ - void setServiceUrlPath(String url); - - /** - * Gets the service url - * - * @return the url - */ - String getServiceUrlPath(); - - /** - * Whether connector should be created, allowing clients to connect remotely - * - * @param createConnector true to create connector - */ - void setCreateConnector(Boolean createConnector); - - /** - * Whether connector is created, allowing clients to connect remotely - * - * @return true if connector is created - */ - Boolean getCreateConnector(); - /** * Whether to use the platform MBean Server. * @@ -351,7 +295,7 @@ public interface ManagementAgent extends Service { * @return the level */ ManagementStatisticsLevel getStatisticsLevel(); - + /** * Gets whether host IP Address to be used instead of host name. * @@ -360,7 +304,7 @@ public interface ManagementAgent extends Service { Boolean getUseHostIPAddress(); /** - * Sets whether to use host IP Address + * Sets whether to use host IP Address * @param useHostIPAddress true to use IP Address. */ void setUseHostIPAddress(Boolean useHostIPAddress); diff --git a/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jmxAgent.json b/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jmxAgent.json index 69d7df5f167bf..dfa5e3cb3100d 100644 --- a/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jmxAgent.json +++ b/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jmxAgent.json @@ -13,12 +13,8 @@ "properties": { "disabled": { "kind": "attribute", "displayName": "Disabled", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Disable JMI (default false)" }, "onlyRegisterProcessorWithCustomId": { "kind": "attribute", "displayName": "Only Register Processor With Custom Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Only register processor if a custom id was defined for it." }, - "registryPort": { "kind": "attribute", "displayName": "Registry Port", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "1099", "description": "RMI connector registry port (default 1099)" }, - "connectorPort": { "kind": "attribute", "displayName": "Connector Port", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "-1", "description": "RMI connector server port (default -1 not used)" }, "mbeanServerDefaultDomain": { "kind": "attribute", "displayName": "Mbean Server Default Domain", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "org.apache.camel", "description": "MBean server default domain name (default org.apache.camel)" }, "mbeanObjectDomainName": { "kind": "attribute", "displayName": "Mbean Object Domain Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "org.apache.camel", "description": "MBean object domain name (default org.apache.camel)" }, - "serviceUrlPath": { "kind": "attribute", "displayName": "Service Url Path", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "\/jmxrmi", "description": "JMX Service URL path (default \/jmxrmi)" }, - "createConnector": { "kind": "attribute", "displayName": "Create Connector", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "false", "description": "A flag that indicates whether the agent should be created" }, "usePlatformMBeanServer": { "kind": "attribute", "displayName": "Use Platform MBean Server", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "true", "description": "A flag that indicates whether the platform mbean server should be used" }, "registerAlways": { "kind": "attribute", "displayName": "Register Always", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "false", "description": "A flag that indicates whether to register mbeans always" }, "registerNewRoutes": { "kind": "attribute", "displayName": "Register New Routes", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "false", "description": "A flag that indicates whether to register mbeans when starting new routes" }, diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java index 6a3887a19c6bd..e90b09b90464d 100644 --- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java +++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java @@ -552,21 +552,9 @@ protected void initJMXAgent() throws Exception { LOG.info("JMXAgent enabled: {}", camelJMXAgent); Map properties = new HashMap<>(); - if (camelJMXAgent.getConnectorPort() != null) { - properties.put("connectorPort", CamelContextHelper.parseInteger(getContext(), camelJMXAgent.getConnectorPort())); - } - if (camelJMXAgent.getCreateConnector() != null) { - properties.put("createConnector", CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getCreateConnector())); - } if (camelJMXAgent.getMbeanObjectDomainName() != null) { properties.put("mbeanObjectDomainName", CamelContextHelper.parseText(getContext(), camelJMXAgent.getMbeanObjectDomainName())); } - if (camelJMXAgent.getRegistryPort() != null) { - properties.put("registryPort", CamelContextHelper.parseInteger(getContext(), camelJMXAgent.getRegistryPort())); - } - if (camelJMXAgent.getServiceUrlPath() != null) { - properties.put("serviceUrlPath", CamelContextHelper.parseText(getContext(), camelJMXAgent.getServiceUrlPath())); - } if (camelJMXAgent.getUsePlatformMBeanServer() != null) { properties.put("usePlatformMBeanServer", CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getUsePlatformMBeanServer())); } diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java index d96a589dad74f..636649128cf01 100644 --- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java +++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java @@ -37,18 +37,10 @@ public class CamelJMXAgentDefinition extends IdentifiedType { private String disabled; @XmlAttribute @Metadata(defaultValue = "false") private String onlyRegisterProcessorWithCustomId; - @XmlAttribute @Metadata(defaultValue = "1099") - private String registryPort; - @XmlAttribute @Metadata(defaultValue = "-1") - private String connectorPort; @XmlAttribute @Metadata(defaultValue = "org.apache.camel") private String mbeanServerDefaultDomain; @XmlAttribute @Metadata(defaultValue = "org.apache.camel") private String mbeanObjectDomainName; - @XmlAttribute @Metadata(defaultValue = "/jmxrmi") - private String serviceUrlPath; - @XmlAttribute @Metadata(defaultValue = "false") - private String createConnector; @XmlAttribute @Metadata(defaultValue = "true") private String usePlatformMBeanServer; @XmlAttribute @Metadata(defaultValue = "false") @@ -90,28 +82,6 @@ public void setOnlyRegisterProcessorWithCustomId(String onlyRegisterProcessorWit this.onlyRegisterProcessorWithCustomId = onlyRegisterProcessorWithCustomId; } - public String getRegistryPort() { - return registryPort; - } - - /** - * RMI connector registry port (default 1099) - */ - public void setRegistryPort(String registryPort) { - this.registryPort = registryPort; - } - - public String getConnectorPort() { - return connectorPort; - } - - /** - * RMI connector server port (default -1 not used) - */ - public void setConnectorPort(String connectorPort) { - this.connectorPort = connectorPort; - } - public String getMbeanServerDefaultDomain() { return mbeanServerDefaultDomain; } @@ -134,28 +104,6 @@ public void setMbeanObjectDomainName(String mbeanObjectDomainName) { this.mbeanObjectDomainName = mbeanObjectDomainName; } - public String getServiceUrlPath() { - return serviceUrlPath; - } - - /** - * JMX Service URL path (default /jmxrmi) - */ - public void setServiceUrlPath(String serviceUrlPath) { - this.serviceUrlPath = serviceUrlPath; - } - - public String getCreateConnector() { - return createConnector; - } - - /** - * A flag that indicates whether the agent should be created - */ - public void setCreateConnector(String createConnector) { - this.createConnector = createConnector; - } - public String getUsePlatformMBeanServer() { return usePlatformMBeanServer; } @@ -267,18 +215,6 @@ public String toString() { if (usePlatformMBeanServer != null) { csb.append("usePlatformMBeanServer=" + usePlatformMBeanServer); } - if (createConnector != null) { - csb.append("createConnector=" + createConnector); - } - if (connectorPort != null) { - csb.append("connectorPort=" + connectorPort); - } - if (registryPort != null) { - csb.append("registryPort=" + registryPort); - } - if (serviceUrlPath != null) { - csb.append("serviceUrlPath=" + serviceUrlPath); - } if (mbeanServerDefaultDomain != null) { csb.append("mbeanServerDefaultDomain=" + mbeanServerDefaultDomain); } diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java index bc8ee06fa582b..311b113e57ffa 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java @@ -71,8 +71,6 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "JavaRoutesExcludePattern": target.setJavaRoutesExcludePattern(property(camelContext, java.lang.String.class, value)); return true; case "javaroutesincludepattern": case "JavaRoutesIncludePattern": target.setJavaRoutesIncludePattern(property(camelContext, java.lang.String.class, value)); return true; - case "jmxcreateconnector": - case "JmxCreateConnector": target.setJmxCreateConnector(property(camelContext, boolean.class, value)); return true; case "jmxenabled": case "JmxEnabled": target.setJmxEnabled(property(camelContext, boolean.class, value)); return true; case "jmxmanagementnamepattern": diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json index 0cfdb353a7f42..7c1167d94a125 100644 --- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json +++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json @@ -34,7 +34,6 @@ { "name": "camel.main.inflightRepositoryBrowseEnabled", "description": "Sets whether the inflight repository should allow browsing each inflight exchange. This is by default disabled as there is a very slight performance overhead when enabled.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean" }, { "name": "camel.main.javaRoutesExcludePattern", "description": "Used for exclusive filtering component scanning of RouteBuilder classes with Component annotation. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma. For example to exclude all classes starting with Bar use: **\/Bar* To exclude all routes form a specific package use: com\/mycompany\/bar\/* To exclude all routes form a specific package and its sub-packages use double wildcards: com\/mycompany\/bar\/** And to exclude all routes from two specific packages use: com\/mycompany\/bar\/*,com\/mycompany\/stuff\/*", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.main.javaRoutesIncludePattern", "description": "Used for inclusive filtering component scanning of RouteBuilder classes with Component annotation. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma. For example to include all classes starting with Foo use: **\/Foo To include all routes form a specific package use: com\/mycompany\/foo\/* To include all routes form a specific package and its sub-packages use double wildcards: com\/mycompany\/foo\/** And to include all routes from two specific packages use: com\/mycompany\/foo\/*,com\/mycompany\/stuff\/*", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, - { "name": "camel.main.jmxCreateConnector", "description": "Whether JMX connector is created, allowing clients to connect remotely The default value is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean" }, { "name": "camel.main.jmxEnabled", "description": "Enable JMX in your Camel application.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, { "name": "camel.main.jmxManagementNamePattern", "description": "The naming pattern for creating the CamelContext JMX management name. The default pattern is #name#", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "#name#" }, { "name": "camel.main.jmxManagementStatisticsLevel", "description": "Sets the JMX statistics level The level can be set to Extended to gather additional information The default value is Default.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "object", "javaType": "org.apache.camel.ManagementStatisticsLevel", "defaultValue": "ManagementStatisticsLevel.Default", "enum": [ "Extended", "Default", "RoutesOnly", "Off" ] }, diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java index a76def97138c1..d945450be6cf2 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java @@ -158,7 +158,6 @@ public static void configure(CamelContext camelContext, DefaultConfigurationProp camelContext.getManagementStrategy().getManagementAgent().setEndpointRuntimeStatisticsEnabled(config.isEndpointRuntimeStatisticsEnabled()); camelContext.getManagementStrategy().getManagementAgent().setStatisticsLevel(config.getJmxManagementStatisticsLevel()); camelContext.getManagementStrategy().getManagementAgent().setManagementNamePattern(config.getJmxManagementNamePattern()); - camelContext.getManagementStrategy().getManagementAgent().setCreateConnector(config.isJmxCreateConnector()); } // global endpoint configurations diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java index 58777be2975cd..bd27e5c003e69 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java @@ -68,7 +68,6 @@ public abstract class DefaultConfigurationProperties { private boolean useBreadcrumb; private ManagementStatisticsLevel jmxManagementStatisticsLevel = ManagementStatisticsLevel.Default; private String jmxManagementNamePattern = "#name#"; - private boolean jmxCreateConnector; private boolean useMdcLogging; private String mdcLoggingKeysPattern; private String threadNamePattern; @@ -660,19 +659,6 @@ public void setJmxManagementNamePattern(String jmxManagementNamePattern) { this.jmxManagementNamePattern = jmxManagementNamePattern; } - public boolean isJmxCreateConnector() { - return jmxCreateConnector; - } - - /** - * Whether JMX connector is created, allowing clients to connect remotely - * - * The default value is false. - */ - public void setJmxCreateConnector(boolean jmxCreateConnector) { - this.jmxCreateConnector = jmxCreateConnector; - } - public boolean isUseMdcLogging() { return useMdcLogging; } @@ -1341,16 +1327,6 @@ public T withJmxManagementNamePattern(String jmxManagementNamePattern) { return (T) this; } - /** - * Whether JMX connector is created, allowing clients to connect remotely - * - * The default value is false. - */ - public T withJmxCreateConnector(boolean jmxCreateConnector) { - this.jmxCreateConnector = jmxCreateConnector; - return (T) this; - } - /** * To turn on MDC logging */ diff --git a/core/camel-management-api/src/main/java/org/apache/camel/api/management/JmxSystemPropertyKeys.java b/core/camel-management-api/src/main/java/org/apache/camel/api/management/JmxSystemPropertyKeys.java index 6ae42e78b68b4..d732a68a61816 100644 --- a/core/camel-management-api/src/main/java/org/apache/camel/api/management/JmxSystemPropertyKeys.java +++ b/core/camel-management-api/src/main/java/org/apache/camel/api/management/JmxSystemPropertyKeys.java @@ -24,24 +24,12 @@ public final class JmxSystemPropertyKeys { // disable jmx public static final String DISABLED = "org.apache.camel.jmx.disabled"; - // jmx (rmi registry) port - public static final String REGISTRY_PORT = "org.apache.camel.jmx.rmiConnector.registryPort"; - - // jmx (rmi server connection) port - public static final String CONNECTOR_PORT = "org.apache.camel.jmx.rmiConnector.connectorPort"; - // jmx domain name public static final String DOMAIN = "org.apache.camel.jmx.mbeanServerDefaultDomain"; // the domain name for the camel mbeans public static final String MBEAN_DOMAIN = "org.apache.camel.jmx.mbeanObjectDomainName"; - // JMX service URL path - public static final String SERVICE_URL_PATH = "org.apache.camel.jmx.serviceUrlPath"; - - // A flag that indicates whether the agent should be created - public static final String CREATE_CONNECTOR = "org.apache.camel.jmx.createRmiConnector"; - // use jvm platform mbean server flag public static final String USE_PLATFORM_MBS = "org.apache.camel.jmx.usePlatformMBeanServer"; 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 5d2d635fe15c0..2f08c08774669 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 @@ -18,13 +18,6 @@ import java.io.IOException; import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.rmi.NoSuchObjectException; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.rmi.server.UnicastRemoteObject; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -38,9 +31,6 @@ import javax.management.NotCompliantMBeanException; import javax.management.ObjectInstance; import javax.management.ObjectName; -import javax.management.remote.JMXConnectorServer; -import javax.management.remote.JMXConnectorServerFactory; -import javax.management.remote.JMXServiceURL; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; @@ -52,9 +42,7 @@ import org.apache.camel.support.management.DefaultManagementMBeanAssembler; import org.apache.camel.support.service.ServiceHelper; import org.apache.camel.support.service.ServiceSupport; -import org.apache.camel.util.InetAddressUtil; import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.StringHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,9 +53,6 @@ public class DefaultManagementAgent extends ServiceSupport implements Management public static final String DEFAULT_DOMAIN = "org.apache.camel"; public static final String DEFAULT_HOST = "localhost"; - public static final int DEFAULT_REGISTRY_PORT = 1099; - public static final int DEFAULT_CONNECTION_PORT = -1; - public static final String DEFAULT_SERVICE_URL_PATH = "/jmxrmi/camel"; private static final Logger LOG = LoggerFactory.getLogger(DefaultManagementAgent.class); private CamelContext camelContext; @@ -76,16 +61,10 @@ public class DefaultManagementAgent extends ServiceSupport implements Management // need a name -> actual name mapping as some servers changes the names (such as WebSphere) private final ConcurrentMap mbeansRegistered = new ConcurrentHashMap<>(); - private JMXConnectorServer cs; - private Registry registry; - private Integer registryPort = DEFAULT_REGISTRY_PORT; - private Integer connectorPort = DEFAULT_CONNECTION_PORT; private String mBeanServerDefaultDomain = DEFAULT_DOMAIN; private String mBeanObjectDomainName = DEFAULT_DOMAIN; - private String serviceUrlPath = DEFAULT_SERVICE_URL_PATH; private Boolean usePlatformMBeanServer = true; - private Boolean createConnector = false; private Boolean onlyRegisterProcessorWithCustomId = false; private Boolean loadStatisticsEnabled = false; private Boolean endpointRuntimeStatisticsEnabled; @@ -108,14 +87,6 @@ protected void finalizeSettings() throws Exception { // JVM system properties take precedence over any configuration Map values = new LinkedHashMap<>(); - if (System.getProperty(JmxSystemPropertyKeys.REGISTRY_PORT) != null) { - registryPort = Integer.getInteger(JmxSystemPropertyKeys.REGISTRY_PORT); - values.put(JmxSystemPropertyKeys.REGISTRY_PORT, registryPort); - } - if (System.getProperty(JmxSystemPropertyKeys.CONNECTOR_PORT) != null) { - connectorPort = Integer.getInteger(JmxSystemPropertyKeys.CONNECTOR_PORT); - values.put(JmxSystemPropertyKeys.CONNECTOR_PORT, connectorPort); - } if (System.getProperty(JmxSystemPropertyKeys.DOMAIN) != null) { mBeanServerDefaultDomain = System.getProperty(JmxSystemPropertyKeys.DOMAIN); values.put(JmxSystemPropertyKeys.DOMAIN, mBeanServerDefaultDomain); @@ -124,14 +95,6 @@ protected void finalizeSettings() throws Exception { mBeanObjectDomainName = System.getProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN); values.put(JmxSystemPropertyKeys.MBEAN_DOMAIN, mBeanObjectDomainName); } - if (System.getProperty(JmxSystemPropertyKeys.SERVICE_URL_PATH) != null) { - serviceUrlPath = System.getProperty(JmxSystemPropertyKeys.SERVICE_URL_PATH); - values.put(JmxSystemPropertyKeys.SERVICE_URL_PATH, serviceUrlPath); - } - if (System.getProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR) != null) { - createConnector = Boolean.getBoolean(JmxSystemPropertyKeys.CREATE_CONNECTOR); - values.put(JmxSystemPropertyKeys.CREATE_CONNECTOR, createConnector); - } if (System.getProperty(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID) != null) { onlyRegisterProcessorWithCustomId = Boolean.getBoolean(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID); values.put(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID, onlyRegisterProcessorWithCustomId); @@ -156,10 +119,6 @@ protected void finalizeSettings() throws Exception { includeHostName = Boolean.getBoolean(JmxSystemPropertyKeys.INCLUDE_HOST_NAME); values.put(JmxSystemPropertyKeys.INCLUDE_HOST_NAME, includeHostName); } - if (System.getProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR) != null) { - createConnector = Boolean.getBoolean(JmxSystemPropertyKeys.CREATE_CONNECTOR); - values.put(JmxSystemPropertyKeys.CREATE_CONNECTOR, createConnector); - } if (System.getProperty(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED) != null) { loadStatisticsEnabled = Boolean.getBoolean(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED); values.put(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED, loadStatisticsEnabled); @@ -186,26 +145,6 @@ protected void finalizeSettings() throws Exception { } } - @Override - public void setRegistryPort(Integer port) { - registryPort = port; - } - - @Override - public Integer getRegistryPort() { - return registryPort; - } - - @Override - public void setConnectorPort(Integer port) { - connectorPort = port; - } - - @Override - public Integer getConnectorPort() { - return connectorPort; - } - @Override public void setMBeanServerDefaultDomain(String domain) { mBeanServerDefaultDomain = domain; @@ -226,26 +165,6 @@ public String getMBeanObjectDomainName() { return mBeanObjectDomainName; } - @Override - public void setServiceUrlPath(String url) { - serviceUrlPath = url; - } - - @Override - public String getServiceUrlPath() { - return serviceUrlPath; - } - - @Override - public void setCreateConnector(Boolean flag) { - createConnector = flag; - } - - @Override - public Boolean getCreateConnector() { - return createConnector; - } - @Override public void setUsePlatformMBeanServer(Boolean flag) { usePlatformMBeanServer = flag; @@ -455,28 +374,6 @@ protected void doStart() throws Exception { @Override protected void doStop() throws Exception { - // close JMX Connector, if it was created - if (cs != null) { - try { - cs.stop(); - LOG.debug("Stopped JMX Connector"); - } catch (IOException e) { - LOG.debug("Error occurred during stopping JMXConnectorService: " - + cs + ". This exception will be ignored."); - } - cs = null; - } - - // Unexport JMX RMI registry, if it was created - if (registry != null) { - try { - UnicastRemoteObject.unexportObject(registry, true); - LOG.debug("Unexported JMX RMI Registry"); - } catch (NoSuchObjectException e) { - LOG.debug("Error occurred while unexporting JMX RMI registry. This exception will be ignored."); - } - } - if (mbeansRegistered.isEmpty()) { return; } @@ -532,45 +429,9 @@ private void registerMBeanWithServer(Object obj, ObjectName name, boolean forceR } protected void createMBeanServer() { - String hostName; - boolean canAccessSystemProps = true; - try { - // we'll do it this way mostly to determine if we should lookup the hostName - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } - } catch (SecurityException se) { - canAccessSystemProps = false; - } - - if (canAccessSystemProps) { - try { - if (useHostIPAddress) { - hostName = InetAddress.getLocalHost().getHostAddress(); - } else { - hostName = InetAddressUtil.getLocalHostName(); - } - } catch (UnknownHostException uhe) { - LOG.info("Cannot determine localhost name or address. Using default: {}", DEFAULT_REGISTRY_PORT, uhe); - hostName = DEFAULT_HOST; - } - } else { - hostName = DEFAULT_HOST; - } - server = findOrCreateMBeanServer(); - - try { - // Create the connector if we need - if (createConnector) { - createJmxConnector(hostName); - } - } catch (IOException ioe) { - LOG.warn("Could not create and start JMX connector.", ioe); - } } - + protected MBeanServer findOrCreateMBeanServer() { // return platform mbean server if the option is specified. @@ -593,43 +454,4 @@ protected MBeanServer findOrCreateMBeanServer() { return MBeanServerFactory.createMBeanServer(mBeanServerDefaultDomain); } - protected void createJmxConnector(String host) throws IOException { - StringHelper.notEmpty(serviceUrlPath, "serviceUrlPath"); - ObjectHelper.notNull(registryPort, "registryPort"); - - try { - registry = LocateRegistry.createRegistry(registryPort); - LOG.debug("Created JMXConnector RMI registry on port {}", registryPort); - } catch (RemoteException ex) { - // The registry may had been created, we could get the registry instead - } - - // must start with leading slash - String path = serviceUrlPath.startsWith("/") ? serviceUrlPath : "/" + serviceUrlPath; - // Create an RMI connector and start it - final JMXServiceURL url; - if (connectorPort > 0) { - url = new JMXServiceURL("service:jmx:rmi://" + host + ":" + connectorPort + "/jndi/rmi://" + host - + ":" + registryPort + path); - } else { - url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + host + ":" + registryPort + path); - } - - cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server); - - // use async thread for starting the JMX Connector - // (no need to use a thread pool or enlist in JMX as this thread is terminated when the JMX connector has been started) - String threadName = camelContext.getExecutorServiceManager().resolveThreadName("JMXConnector: " + url); - Thread thread = getCamelContext().getExecutorServiceManager().newThread(threadName, () -> { - try { - LOG.debug("Staring JMX Connector thread to listen at: {}", url); - cs.start(); - LOG.info("JMX Connector thread started and listening at: {}", url); - } catch (IOException ioe) { - LOG.warn("Could not start JMXConnector thread at: " + url + ". JMX Connector not in use.", ioe); - } - }); - thread.start(); - } - } diff --git a/core/camel-management/src/test/java/org/apache/camel/management/DefaultManagementAgentMockTest.java b/core/camel-management/src/test/java/org/apache/camel/management/DefaultManagementAgentMockTest.java index ecd0686acefd0..6397ba7cc98bf 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/DefaultManagementAgentMockTest.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/DefaultManagementAgentMockTest.java @@ -76,7 +76,6 @@ public void testObjectNameModification() throws JMException { @Test public void testShouldUseHostIPAddressWhenFlagisTrue() throws Exception { System.setProperty(JmxSystemPropertyKeys.USE_HOST_IP_ADDRESS, "true"); - System.setProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR, "true"); CamelContext ctx = new DefaultCamelContext(); ManagementAgent agent = new DefaultManagementAgent(ctx); @@ -88,7 +87,6 @@ public void testShouldUseHostIPAddressWhenFlagisTrue() throws Exception { @Test public void shouldUseHostNameWhenFlagisFalse() throws Exception { System.setProperty(JmxSystemPropertyKeys.USE_HOST_IP_ADDRESS, "false"); - System.setProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR, "true"); CamelContext ctx = new DefaultCamelContext(); ManagementAgent agent = new DefaultManagementAgent(ctx); diff --git a/core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java b/core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java index 1ff4d13292b50..fc5a9bc88b822 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java @@ -205,8 +205,6 @@ public void tearDown() throws Exception { System.clearProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS); System.clearProperty(JmxSystemPropertyKeys.DOMAIN); System.clearProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN); - System.clearProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR); - System.clearProperty(JmxSystemPropertyKeys.REGISTRY_PORT); } } diff --git a/core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java b/core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java deleted file mode 100644 index a3d9bf3155672..0000000000000 --- a/core/camel-management/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.rmi.NoSuchObjectException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.util.Locale; -import java.util.Random; - -import javax.management.MBeanServerConnection; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; - -import org.apache.camel.api.management.JmxSystemPropertyKeys; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * Test that verifies JMX connector server can be connected by - * a client. - */ -public class JmxInstrumentationWithConnectorTest extends JmxInstrumentationUsingDefaultsTest { - - protected String url; - protected JMXConnector clientConnector; - protected int registryPort; - - @Override - protected boolean useJmx() { - return true; - } - - @Override - protected boolean canRunOnThisPlatform() { - String os = System.getProperty("os.name"); - boolean aix = os.toLowerCase(Locale.ENGLISH).contains("aix"); - boolean windows = os.toLowerCase(Locale.ENGLISH).contains("windows"); - boolean solaris = os.toLowerCase(Locale.ENGLISH).contains("sunos"); - - // Does not work on AIX / solaris and the problem is hard to identify, could be issues not allowing to use a custom port - // java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmxrmi/camel - - // windows CI servers is often slow/tricky so skip as well - return !aix && !solaris && !windows; - } - - @Override - @Before - public void setUp() throws Exception { - registryPort = 30000 + new Random().nextInt(10000); - log.info("Using port " + registryPort); - url = "service:jmx:rmi:///jndi/rmi://localhost:" + registryPort + "/jmxrmi/camel"; - - // need to explicit set it to false to use non-platform mbs - System.setProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS, "false"); - System.setProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR, "true"); - System.setProperty(JmxSystemPropertyKeys.REGISTRY_PORT, "" + registryPort); - super.setUp(); - } - - @Override - @After - public void tearDown() throws Exception { - if (clientConnector != null) { - try { - clientConnector.close(); - } catch (Exception e) { - // ignore - } - clientConnector = null; - } - // restore environment to original state - // the following properties may have been set by specialization of this test class - System.clearProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS); - System.clearProperty(JmxSystemPropertyKeys.DOMAIN); - System.clearProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN); - System.clearProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR); - System.clearProperty(JmxSystemPropertyKeys.REGISTRY_PORT); - - super.tearDown(); - } - - @Override - protected MBeanServerConnection getMBeanConnection() throws Exception { - if (mbsc == null) { - if (clientConnector == null) { - clientConnector = JMXConnectorFactory.connect(new JMXServiceURL(url), null); - } - mbsc = clientConnector.getMBeanServerConnection(); - } - return mbsc; - } - - @Test - public void testRmiRegistryUnexported() throws Exception { - - Registry registry = LocateRegistry.getRegistry(registryPort); - - // before we stop the context the registry is still exported, so list() should work - Exception e; - try { - registry.list(); - e = null; - } catch (NoSuchObjectException nsoe) { - e = nsoe; - } - assertNull(e); - - // stop the Camel context - context.stop(); - - // stopping the Camel context unexported the registry, so list() should fail - Exception e2; - try { - registry.list(); - e2 = null; - } catch (NoSuchObjectException nsoe) { - e2 = nsoe; - } - assertNotNull(e2); - } -} diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedComponentTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedComponentTest.java index 244e656e7dd5a..a5da9431ec6df 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedComponentTest.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedComponentTest.java @@ -43,7 +43,6 @@ public class ManagedComponentTest extends ManagementTestSupport { protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); context.init(); - context.getManagementStrategy().getManagementAgent().setCreateConnector(true); context.addComponent("my-verifiable-component", new MyVerifiableComponent()); context.addComponent("direct", new DirectComponent()); diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteWithOnExceptionTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteWithOnExceptionTest.java index 3d1e8e16132f4..ca1b84151d09b 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteWithOnExceptionTest.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteWithOnExceptionTest.java @@ -19,26 +19,10 @@ import org.apache.camel.CamelExecutionException; import org.apache.camel.api.management.JmxSystemPropertyKeys; import org.apache.camel.builder.RouteBuilder; -import org.junit.After; -import org.junit.Before; import org.junit.Test; public class ManagedRouteWithOnExceptionTest extends ManagementTestSupport { - @Override - @Before - public void setUp() throws Exception { - System.setProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR, "true"); - super.setUp(); - } - - @Override - @After - public void tearDown() throws Exception { - System.clearProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR); - super.tearDown(); - } - @Test public void testShouldBeInstrumentedOk() throws Exception { getMockEndpoint("mock:error").expectedMessageCount(0); diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedServiceUrlPathTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedServiceUrlPathTest.java deleted file mode 100644 index 9ff0e0497ba8c..0000000000000 --- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedServiceUrlPathTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 javax.management.MBeanServerConnection; -import javax.management.ObjectName; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.junit.After; -import org.junit.Test; - -public class ManagedServiceUrlPathTest extends ManagementTestSupport { - - private static final String JMXSERVICEURL = "service:jmx:rmi:///jndi/rmi://localhost:2113/foo/bar"; - private JMXConnector clientConnector; - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext context = super.createCamelContext(); - - // START SNIPPET: e1 - context.getManagementStrategy().getManagementAgent().setServiceUrlPath("/foo/bar"); - context.getManagementStrategy().getManagementAgent().setRegistryPort(2113); - context.getManagementStrategy().getManagementAgent().setCreateConnector(true); - // END SNIPPET: e1 - - return context; - } - - @Override - protected boolean canRunOnThisPlatform() { - // does not work well when maven surefire plugin is set to forkmode=once - return false; - } - - @Override - @After - public void tearDown() throws Exception { - super.tearDown(); - try { - if (clientConnector != null) { - clientConnector.close(); - } - } catch (Throwable e) { - // ignore - } - } - - @Test - public void testConnectToJmx() throws Exception { - // JMX tests dont work well on AIX CI servers (hangs them) - if (isPlatform("aix")) { - return; - } - - clientConnector = JMXConnectorFactory.connect(new JMXServiceURL(JMXSERVICEURL), null); - MBeanServerConnection mbeanServer = clientConnector.getMBeanServerConnection(); - - ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"direct://start\""); - String uri = (String) mbeanServer.getAttribute(name, "EndpointUri"); - assertEquals("direct://start", uri); - - name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"log://foo\""); - uri = (String) mbeanServer.getAttribute(name, "EndpointUri"); - assertEquals("log://foo", uri); - - name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://result\""); - uri = (String) mbeanServer.getAttribute(name, "EndpointUri"); - assertEquals("mock://result", uri); - - String id = (String) mbeanServer.getAttribute(name, "CamelId"); - assertEquals("camel-1", id); - - Boolean singleton = (Boolean) mbeanServer.getAttribute(name, "Singleton"); - assertEquals(Boolean.TRUE, singleton); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start").to("log:foo").to("mock:result"); - } - }; - } - -} diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagementTestSupport.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagementTestSupport.java index fb9dbc59bd2d0..2965622867a89 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/ManagementTestSupport.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagementTestSupport.java @@ -26,35 +26,17 @@ import javax.management.ReflectionException; import org.apache.camel.ContextTestSupport; -import org.apache.camel.api.management.JmxSystemPropertyKeys; -import org.apache.camel.management.util.AvailablePortFinder; -import org.junit.Before; /** * Base class for JMX tests. */ public abstract class ManagementTestSupport extends ContextTestSupport { - protected int registryPort; - protected String url; - @Override protected boolean useJmx() { return true; } - @Override - @Before - public void setUp() throws Exception { - registryPort = AvailablePortFinder.getNextAvailable(); - log.info("Using port " + registryPort); - - // need to explicit set it to false to use non-platform mbs - System.setProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR, "true"); - System.setProperty(JmxSystemPropertyKeys.REGISTRY_PORT, "" + registryPort); - super.setUp(); - } - protected MBeanServer getMBeanServer() { return context.getManagementStrategy().getManagementAgent().getMBeanServer(); } diff --git a/docs/components/modules/ROOT/pages/influxdb-component.adoc b/docs/components/modules/ROOT/pages/influxdb-component.adoc index 7a32db851ae15..bc2ea3ccef9fc 100644 --- a/docs/components/modules/ROOT/pages/influxdb-component.adoc +++ b/docs/components/modules/ROOT/pages/influxdb-component.adoc @@ -47,13 +47,14 @@ configured in the registry, using the native java driver. // component options: START -The InfluxDB component supports 2 options, which are listed below. +The InfluxDB component supports 3 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type +| *influxDB* (producer) | The shared Influx DB to use for all endpoints | | InfluxDB | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean |=== diff --git a/docs/components/modules/ROOT/pages/nats-component.adoc b/docs/components/modules/ROOT/pages/nats-component.adoc index 4bd5d30fbc227..a80b3913c8190 100644 --- a/docs/components/modules/ROOT/pages/nats-component.adoc +++ b/docs/components/modules/ROOT/pages/nats-component.adoc @@ -36,7 +36,7 @@ Where *topic* is the topic name // component options: START -The Nats component supports 5 options, which are listed below. +The Nats component supports 6 options, which are listed below. @@ -44,6 +44,7 @@ The Nats component supports 5 options, which are listed below. |=== | Name | Description | Default | Type | *servers* (common) | URLs to one or more NAT servers. Use comma to separate URLs when specifying multiple servers. | | String +| *verbose* (common) | Whether or not running in verbose mode | false | boolean | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean @@ -87,7 +88,7 @@ with the following path and query parameters: | *maxReconnectAttempts* (common) | Max reconnection attempts | 60 | int | *noEcho* (common) | Turn off echo. If supported by the gnatsd version you are connecting to this flag will prevent the server from echoing messages back to the connection if it has subscriptions on the subject being published to. | false | boolean | *noRandomizeServers* (common) | Whether or not randomizing the order of servers for the connection attempts | false | boolean -| *pedantic* (common) | Whether or not running in pedantic mode (this affects performace) | false | boolean +| *pedantic* (common) | Whether or not running in pedantic mode (this affects performance) | false | boolean | *pingInterval* (common) | Ping interval to be aware if connection is still alive (in milliseconds) | 120000 | int | *reconnect* (common) | Whether or not using reconnection feature | true | boolean | *reconnectTimeWait* (common) | Waiting time before attempts reconnection (in milliseconds) | 2000 | int diff --git a/docs/user-manual/modules/ROOT/pages/jmx.adoc b/docs/user-manual/modules/ROOT/pages/jmx.adoc index 2a38310ca3ae0..bf4255dec337d 100644 --- a/docs/user-manual/modules/ROOT/pages/jmx.adoc +++ b/docs/user-manual/modules/ROOT/pages/jmx.adoc @@ -124,7 +124,7 @@ property. The `MBeanServer` default domain name configuration is ignored as it is not applicable. [CAUTION] -Starting in next release (1.5), the default +Starting from the 1.5 release, the default value of `usePlatformMBeanServer` will be changed to `true`. You can set the property to `false` to disable using platform `MBeanServer`. @@ -146,6 +146,9 @@ Spring configuration: == Creating JMX RMI Connector Server +[CAUTION] +Starting from Camel 3.2.0, the configuration in this section no longer applies. + JMX connector server enables MBeans to be remotely managed by a JMX client such as JConsole; Camel JMX RMI connector server can be optionally turned on by setting system property and the `MBeanServer` @@ -169,6 +172,9 @@ Spring configuration: == JMX Service URL +[CAUTION] +Starting from Camel 3.2.0, the configuration in this section no longer applies. + The default JMX Service URL has the format: [source] @@ -358,7 +364,7 @@ information here, like the connector's port or the path name. [source,xml] ---- - + @@ -404,17 +410,17 @@ Camel directly, you'll have to pass these parameters yourself.) |`mbeanObjectDomainName` |`org.apache.camel.jmx.mbeanObjectDomainName` |`org.apache.camel` |The JMX domain that all object names will use -|`createConnector` |`org.apache.camel.jmx.createRmiConnect` |`false` |If +|*Removed in 3.2.0:* `createConnector` |`org.apache.camel.jmx.createRmiConnect` |`false` |If we should create a JMX connector (to allow remote management) for the `MBeanServer` -|`registryPort` |`org.apache.camel.jmx.rmiConnector.registryPort` +|*Removed in 3.2.0:* `registryPort` |`org.apache.camel.jmx.rmiConnector.registryPort` |`1099` |The port that the JMX RMI registry will use -|`connectorPort` |`org.apache.camel.jmx.rmiConnector.connectorPort` |-1 +|*Removed in 3.2.0:* `connectorPort` |`org.apache.camel.jmx.rmiConnector.connectorPort` |-1 (dynamic) |The port that the JMX RMI server will use -|`serviceUrlPath` |`org.apache.camel.jmx.serviceUrlPath` +|*Removed in 3.2.0:* `serviceUrlPath` |`org.apache.camel.jmx.serviceUrlPath` |`/jmxrmi/camel` |The path that JMX connector will be registered under |`onlyRegisterProcessorWithCustomId` diff --git a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MyConfiguration.java b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MyConfiguration.java index b505b254902e0..7d97017d178a2 100644 --- a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MyConfiguration.java +++ b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MyConfiguration.java @@ -57,7 +57,6 @@ public class MyConfiguration { private boolean useDataType; private boolean useBreadcrumb; private String jmxManagementNamePattern = "#name#"; - private boolean jmxCreateConnector; private boolean useMdcLogging; private String threadNamePattern; private String routeFilterIncludePattern; @@ -511,18 +510,6 @@ public void setJmxManagementNamePattern(String jmxManagementNamePattern) { this.jmxManagementNamePattern = jmxManagementNamePattern; } - public boolean isJmxCreateConnector() { - return jmxCreateConnector; - } - - /** - * Whether JMX connector is created, allowing clients to connect remotely - * The default value is false. - */ - public void setJmxCreateConnector(boolean jmxCreateConnector) { - this.jmxCreateConnector = jmxCreateConnector; - } - public boolean isUseMdcLogging() { return useMdcLogging; }