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 2021/04/21 12:22:21 UTC
[camel] branch main updated: CAMEL-16535: Add option to dump routes
as XML on startup
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 6a6f054 CAMEL-16535: Add option to dump routes as XML on startup
6a6f054 is described below
commit 6a6f05487f830bf256f2ab5bbbe34c9bdbeb2438
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 21 14:20:13 2021 +0200
CAMEL-16535: Add option to dump routes as XML on startup
---
.../main/camel-main-configuration-metadata.json | 1 +
.../main/java/org/apache/camel/CamelContext.java | 26 ++++++++++
.../camel/impl/engine/AbstractCamelContext.java | 19 ++++++++
.../camel/impl/ExtendedCamelContextConfigurer.java | 6 +++
.../org/apache/camel/impl/DefaultCamelContext.java | 57 ++++++++++++++++++++++
.../camel/impl/lw/LightweightCamelContext.java | 10 ++++
.../impl/lw/LightweightRuntimeCamelContext.java | 12 +++++
.../core/xml/AbstractCamelContextFactoryBean.java | 5 ++
.../MainConfigurationPropertiesConfigurer.java | 6 +++
.../camel-main-configuration-metadata.json | 1 +
core/camel-main/src/main/docs/main.adoc | 1 +
.../camel/main/DefaultConfigurationConfigurer.java | 1 +
.../camel/main/DefaultConfigurationProperties.java | 32 ++++++++++++
docs/components/modules/others/pages/main.adoc | 1 +
14 files changed, 178 insertions(+)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 025eed5..33981f1 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -26,6 +26,7 @@
{ "name": "camel.main.configurationClasses", "description": "Sets classes names that will be used to configure the camel context as example by providing custom beans through org.apache.camel.BindToRegistry annotation.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.main.configurations", "description": "Sets the configuration objects used to configure the camel context.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "object", "javaType": "java.util.List" },
{ "name": "camel.main.consumerTemplateCacheSize", "description": "Consumer template endpoints cache size.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 1000 },
+ { "name": "camel.main.dumpRoutes", "description": "If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates) represented as XML DSL into the log. This is intended for trouble shooting or to assist during development. Sensitive information that may be configured in the route endpoints could potentially be included in the dump output and is therefore not recommended to be used for production usage. This requires to have camel-xml-jaxb [...]
{ "name": "camel.main.durationHitExitCode", "description": "Sets the exit code for the application if duration was hit", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "integer", "javaType": "int" },
{ "name": "camel.main.durationMaxIdleSeconds", "description": "To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. You can use this to run Camel for a short while.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int" },
{ "name": "camel.main.durationMaxMessages", "description": "To specify how many messages to process by Camel before automatic terminating the JVM. You can use this to run Camel for a short while.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int" },
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
index 38df764f..5053093 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
@@ -1199,6 +1199,32 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
void setMDCLoggingKeysPattern(String pattern);
/**
+ * If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates)
+ * represented as XML DSL into the log. This is intended for trouble shooting or to assist during development.
+ *
+ * Sensitive information that may be configured in the route endpoints could potentially be included in the dump
+ * output and is therefore not recommended to be used for production usage.
+ *
+ * This requires to have camel-xml-jaxb on the classpath to be able to dump the routes as XML.
+ *
+ * @return <tt>true</tt> if dumping is enabled
+ */
+ Boolean isDumpRoutes();
+
+ /**
+ * If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates)
+ * represented as XML DSL into the log. This is intended for trouble shooting or to assist during development.
+ *
+ * Sensitive information that may be configured in the route endpoints could potentially be included in the dump
+ * output and is therefore not recommended to be used for production usage.
+ *
+ * This requires to have camel-xml-jaxb on the classpath to be able to dump the routes as XML.
+ *
+ * @param dumpRoutes <tt>true</tt> to enable dumping routes.
+ */
+ void setDumpRoutes(Boolean dumpRoutes);
+
+ /**
* Whether to enable using data type on Camel messages.
* <p/>
* Data type are automatic turned on if one ore more routes has been explicit configured with input and output
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index c1d8fd1..b73bb94 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -256,6 +256,7 @@ public abstract class AbstractCamelContext extends BaseService
private Boolean disableJMX = Boolean.FALSE;
private Boolean loadTypeConverters = Boolean.FALSE;
private Boolean typeConverterStatisticsEnabled = Boolean.FALSE;
+ private Boolean dumpRoutes = Boolean.FALSE;
private Boolean useMDCLogging = Boolean.FALSE;
private String mdcLoggingKeysPattern;
private Boolean useDataType = Boolean.FALSE;
@@ -3159,6 +3160,10 @@ public abstract class AbstractCamelContext extends BaseService
LOG.debug("Skip starting routes as CamelContext has been configured with autoStartup=false");
}
+ if (isDumpRoutes() != null && isDumpRoutes()) {
+ doDumpRoutes();
+ }
+
// invoke this logic to warmup the routes and if possible also start the routes
StartupStep subStep = startupStepRecorder.beginStep(CamelContext.class, getName(), "Start Routes");
EventHelper.notifyCamelContextRoutesStarting(this);
@@ -3350,6 +3355,10 @@ public abstract class AbstractCamelContext extends BaseService
firstStartDone = false;
}
+ protected void doDumpRoutes() {
+ // noop
+ }
+
protected void logRouteStopSummary() {
if (LOG.isInfoEnabled()) {
int total = 0;
@@ -4084,6 +4093,16 @@ public abstract class AbstractCamelContext extends BaseService
}
@Override
+ public Boolean isDumpRoutes() {
+ return dumpRoutes;
+ }
+
+ @Override
+ public void setDumpRoutes(Boolean dumpRoutes) {
+ this.dumpRoutes = dumpRoutes;
+ }
+
+ @Override
public Boolean isUseMDCLogging() {
return useMDCLogging != null && useMDCLogging;
}
diff --git a/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java b/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
index 9d5d73a..014bac5 100644
--- a/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
+++ b/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
@@ -61,6 +61,8 @@ public class ExtendedCamelContextConfigurer extends org.apache.camel.support.com
case "DeferServiceFactory": target.setDeferServiceFactory(property(camelContext, org.apache.camel.spi.DeferServiceFactory.class, value)); return true;
case "delayer":
case "Delayer": target.setDelayer(property(camelContext, java.lang.Long.class, value)); return true;
+ case "dumproutes":
+ case "DumpRoutes": target.setDumpRoutes(property(camelContext, java.lang.Boolean.class, value)); return true;
case "errorhandlerfactory":
case "ErrorHandlerFactory": target.setErrorHandlerFactory(property(camelContext, org.apache.camel.ErrorHandlerFactory.class, value)); return true;
case "eventnotificationapplicable":
@@ -236,6 +238,8 @@ public class ExtendedCamelContextConfigurer extends org.apache.camel.support.com
case "DeferServiceFactory": return org.apache.camel.spi.DeferServiceFactory.class;
case "delayer":
case "Delayer": return java.lang.Long.class;
+ case "dumproutes":
+ case "DumpRoutes": return java.lang.Boolean.class;
case "errorhandlerfactory":
case "ErrorHandlerFactory": return org.apache.camel.ErrorHandlerFactory.class;
case "eventnotificationapplicable":
@@ -412,6 +416,8 @@ public class ExtendedCamelContextConfigurer extends org.apache.camel.support.com
case "DeferServiceFactory": return target.getDeferServiceFactory();
case "delayer":
case "Delayer": return target.getDelayer();
+ case "dumproutes":
+ case "DumpRoutes": return target.isDumpRoutes();
case "errorhandlerfactory":
case "ErrorHandlerFactory": return target.getErrorHandlerFactory();
case "eventnotificationapplicable":
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 0580d7d..87a2741 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -65,6 +65,7 @@ import org.apache.camel.spi.DataFormat;
import org.apache.camel.spi.DataType;
import org.apache.camel.spi.ExecutorServiceManager;
import org.apache.camel.spi.ModelReifierFactory;
+import org.apache.camel.spi.ModelToXMLDumper;
import org.apache.camel.spi.PackageScanClassResolver;
import org.apache.camel.spi.PropertiesComponent;
import org.apache.camel.spi.Registry;
@@ -124,6 +125,62 @@ public class DefaultCamelContext extends SimpleCamelContext implements ModelCame
}
}
+ @Override
+ protected void doDumpRoutes() {
+ ModelToXMLDumper dumper = getModelToXMLDumper();
+
+ getRouteDefinitions()
+
+ int size = getRouteDefinitions().size();
+ if (size > 0) {
+ LOG.info("Dumping {} routes as XML", size);
+ LOG.info("================================================================================");
+ for (int i = 0; i < size; i++) {
+ RouteDefinition def = getRouteDefinitions().get(i);
+ try {
+ String xml = dumper.dumpModelAsXml(this, def, true, true);
+ LOG.info("#{} (route: {})\n{}\n", i + 1, def.getRouteId(), xml);
+ } catch (Exception e) {
+ LOG.warn("Error dumping route to XML due to " + e.getMessage() + ". This exception is ignored.", e);
+ }
+ }
+ LOG.info("================================================================================");
+ }
+
+ size = getRestDefinitions().size();
+ if (size > 0) {
+ LOG.info("Dumping {} rests as XML", size);
+ LOG.info("================================================================================");
+ for (int i = 0; i < size; i++) {
+ RestDefinition def = getRestDefinitions().get(i);
+ try {
+ String xml = dumper.dumpModelAsXml(this, def, true, true);
+ LOG.info("#{} (rest: {})\n{}\n", i + 1, def.getPath(), xml);
+ } catch (Exception e) {
+ LOG.warn("Error dumping rest to XML due to " + e.getMessage() + ". This exception is ignored.", e);
+ }
+ }
+ LOG.info("================================================================================");
+ }
+
+ size = getRouteTemplateDefinitions().size();
+ if (size > 0) {
+ LOG.info("Dumping {} route templates as XML", size);
+ LOG.info("================================================================================");
+ for (int i = 0; i < size; i++) {
+ RouteTemplateDefinition def = getRouteTemplateDefinitions().get(i);
+ try {
+ String xml = dumper.dumpModelAsXml(this, def, true, true);
+ LOG.info("#{} (route-template: {})\n{}\n", i + 1, def.getId(), xml);
+ } catch (Exception e) {
+ LOG.warn("Error dumping route-template to XML due to " + e.getMessage() + ". This exception is ignored.",
+ e);
+ }
+ }
+ LOG.info("================================================================================");
+ }
+ }
+
public static void setNoStart(boolean b) {
getOptions().noStart = b;
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
index 626d4cf..9ffb1f5 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
@@ -867,6 +867,16 @@ public class LightweightCamelContext implements ExtendedCamelContext, CatalogCam
}
@Override
+ public Boolean isDumpRoutes() {
+ return delegate.isDumpRoutes();
+ }
+
+ @Override
+ public void setDumpRoutes(Boolean dumpRoutes) {
+ delegate.setDumpRoutes(dumpRoutes);
+ }
+
+ @Override
public Boolean isUseMDCLogging() {
return delegate.isUseMDCLogging();
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
index d70e23d..66ec1d4 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
@@ -190,6 +190,7 @@ public class LightweightRuntimeCamelContext implements ExtendedCamelContext, Cat
private final boolean eventNotificationApplicable;
private final boolean useDataType;
private final boolean useBreadcrumb;
+ private final boolean dumpRoutes;
private final String mdcLoggingKeysPattern;
private final boolean useMDCLogging;
private final List<Route> routes;
@@ -237,6 +238,7 @@ public class LightweightRuntimeCamelContext implements ExtendedCamelContext, Cat
eventNotificationApplicable = context.adapt(ExtendedCamelContext.class).isEventNotificationApplicable();
useDataType = context.isUseDataType();
useBreadcrumb = context.isUseBreadcrumb();
+ dumpRoutes = context.isDumpRoutes();
mdcLoggingKeysPattern = context.getMDCLoggingKeysPattern();
useMDCLogging = context.isUseMDCLogging();
messageHistory = context.isMessageHistory();
@@ -1163,6 +1165,16 @@ public class LightweightRuntimeCamelContext implements ExtendedCamelContext, Cat
}
@Override
+ public Boolean isDumpRoutes() {
+ return dumpRoutes;
+ }
+
+ @Override
+ public void setDumpRoutes(Boolean dumpRoutes) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public Boolean isUseMDCLogging() {
return useMDCLogging;
}
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 f0f844f..a0b3be8 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
@@ -914,6 +914,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
public abstract String getMDCLoggingKeysPattern();
+ public abstract String getDumpRoutes();
+
public abstract String getUseDataType();
public abstract String getUseBreadcrumb();
@@ -1054,6 +1056,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
if (getMDCLoggingKeysPattern() != null) {
context.setMDCLoggingKeysPattern(CamelContextHelper.parseText(context, getMDCLoggingKeysPattern()));
}
+ if (getDumpRoutes() != null) {
+ context.setDumpRoutes(CamelContextHelper.parseBoolean(context, getDumpRoutes()));
+ }
if (getUseDataType() != null) {
context.setUseDataType(CamelContextHelper.parseBoolean(context, getUseDataType()));
}
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 cdad189..f148bb5 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
@@ -53,6 +53,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
case "Configurations": target.setConfigurations(property(camelContext, java.util.List.class, value)); return true;
case "consumertemplatecachesize":
case "ConsumerTemplateCacheSize": target.setConsumerTemplateCacheSize(property(camelContext, int.class, value)); return true;
+ case "dumproutes":
+ case "DumpRoutes": target.setDumpRoutes(property(camelContext, boolean.class, value)); return true;
case "durationhitexitcode":
case "DurationHitExitCode": target.setDurationHitExitCode(property(camelContext, int.class, value)); return true;
case "durationmaxidleseconds":
@@ -244,6 +246,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
case "Configurations": return java.util.List.class;
case "consumertemplatecachesize":
case "ConsumerTemplateCacheSize": return int.class;
+ case "dumproutes":
+ case "DumpRoutes": return boolean.class;
case "durationhitexitcode":
case "DurationHitExitCode": return int.class;
case "durationmaxidleseconds":
@@ -436,6 +440,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
case "Configurations": return target.getConfigurations();
case "consumertemplatecachesize":
case "ConsumerTemplateCacheSize": return target.getConsumerTemplateCacheSize();
+ case "dumproutes":
+ case "DumpRoutes": return target.isDumpRoutes();
case "durationhitexitcode":
case "DurationHitExitCode": return target.getDurationHitExitCode();
case "durationmaxidleseconds":
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 025eed5..33981f1 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
@@ -26,6 +26,7 @@
{ "name": "camel.main.configurationClasses", "description": "Sets classes names that will be used to configure the camel context as example by providing custom beans through org.apache.camel.BindToRegistry annotation.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.main.configurations", "description": "Sets the configuration objects used to configure the camel context.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "object", "javaType": "java.util.List" },
{ "name": "camel.main.consumerTemplateCacheSize", "description": "Consumer template endpoints cache size.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 1000 },
+ { "name": "camel.main.dumpRoutes", "description": "If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates) represented as XML DSL into the log. This is intended for trouble shooting or to assist during development. Sensitive information that may be configured in the route endpoints could potentially be included in the dump output and is therefore not recommended to be used for production usage. This requires to have camel-xml-jaxb [...]
{ "name": "camel.main.durationHitExitCode", "description": "Sets the exit code for the application if duration was hit", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "integer", "javaType": "int" },
{ "name": "camel.main.durationMaxIdleSeconds", "description": "To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. You can use this to run Camel for a short while.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int" },
{ "name": "camel.main.durationMaxMessages", "description": "To specify how many messages to process by Camel before automatic terminating the JVM. You can use this to run Camel for a short while.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int" },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 3d82806..372feba 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -38,6 +38,7 @@ The following table lists all the options:
| *camel.main.configuration{zwsp}Classes* | Sets classes names that will be used to configure the camel context as example by providing custom beans through org.apache.camel.BindToRegistry annotation. | | String
| *camel.main.configurations* | Sets the configuration objects used to configure the camel context. | | List
| *camel.main.consumerTemplate{zwsp}CacheSize* | Consumer template endpoints cache size. | 1000 | int
+| *camel.main.dumpRoutes* | If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates) represented as XML DSL into the log. This is intended for trouble shooting or to assist during development. Sensitive information that may be configured in the route endpoints could potentially be included in the dump output and is therefore not recommended to be used for production usage. This requires to have camel-xml-jaxb on the classpath to be able [...]
| *camel.main.durationHitExitCode* | Sets the exit code for the application if duration was hit | | int
| *camel.main.durationMaxIdle{zwsp}Seconds* | To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. You can use this to run Camel for a short while. | | int
| *camel.main.durationMaxMessages* | To specify how many messages to process by Camel before automatic terminating the JVM. You can use this to run Camel for a short while. | | int
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 d4bbe00..01c9b13 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
@@ -220,6 +220,7 @@ public final class DefaultConfigurationConfigurer {
camelContext.setAutowiredEnabled(config.isAutowiredEnabled());
camelContext.setUseBreadcrumb(config.isUseBreadcrumb());
camelContext.setUseDataType(config.isUseDataType());
+ camelContext.setDumpRoutes(config.isDumpRoutes());
camelContext.setUseMDCLogging(config.isUseMdcLogging());
camelContext.setMDCLoggingKeysPattern(config.getMdcLoggingKeysPattern());
camelContext.setLoadTypeConverters(config.isLoadTypeConverters());
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 b874fb4..0f25e65 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
@@ -94,6 +94,7 @@ public abstract class DefaultConfigurationProperties<T> {
private String exchangeFactory = "default";
private int exchangeFactoryCapacity = 100;
private boolean exchangeFactoryStatisticsEnabled;
+ private boolean dumpRoutes;
// route controller
@Metadata(defaultValue = "DEBUG")
@Deprecated
@@ -997,6 +998,23 @@ public abstract class DefaultConfigurationProperties<T> {
this.exchangeFactoryStatisticsEnabled = exchangeFactoryStatisticsEnabled;
}
+ public boolean isDumpRoutes() {
+ return dumpRoutes;
+ }
+
+ /**
+ * If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates)
+ * represented as XML DSL into the log. This is intended for trouble shooting or to assist during development.
+ *
+ * Sensitive information that may be configured in the route endpoints could potentially be included in the dump
+ * output and is therefore not recommended to be used for production usage.
+ *
+ * This requires to have camel-xml-jaxb on the classpath to be able to dump the routes as XML.
+ */
+ public void setDumpRoutes(boolean dumpRoutes) {
+ this.dumpRoutes = dumpRoutes;
+ }
+
@Deprecated
public LoggingLevel getRouteControllerLoggingLevel() {
return routeControllerLoggingLevel;
@@ -1886,6 +1904,20 @@ public abstract class DefaultConfigurationProperties<T> {
}
/**
+ * If enable then Camel will during startup dump all loaded routes (incl rests and route templates) represented as
+ * XML DSL into the log. This is intended for trouble shooting or to assist during development.
+ *
+ * Sensitive information that may be configured in the route endpoints could potentially be included in the dump
+ * output and is therefore not recommended to be used for production usage.
+ *
+ * This requires to have camel-xml-jaxb on the classpath to be able to dump the routes as XML.
+ */
+ public T withDumpRoutes(boolean dumpRoutes) {
+ this.dumpRoutes = dumpRoutes;
+ return (T) this;
+ }
+
+ /**
* Sets the logging level used for logging route activity (such as starting and stopping routes). The default
* logging level is DEBUG.
*/
diff --git a/docs/components/modules/others/pages/main.adoc b/docs/components/modules/others/pages/main.adoc
index 55ce95b..ac882d6 100644
--- a/docs/components/modules/others/pages/main.adoc
+++ b/docs/components/modules/others/pages/main.adoc
@@ -40,6 +40,7 @@ The following table lists all the options:
| *camel.main.configuration{zwsp}Classes* | Sets classes names that will be used to configure the camel context as example by providing custom beans through org.apache.camel.BindToRegistry annotation. | | String
| *camel.main.configurations* | Sets the configuration objects used to configure the camel context. | | List
| *camel.main.consumerTemplate{zwsp}CacheSize* | Consumer template endpoints cache size. | 1000 | int
+| *camel.main.dumpRoutes* | If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates) represented as XML DSL into the log. This is intended for trouble shooting or to assist during development. Sensitive information that may be configured in the route endpoints could potentially be included in the dump output and is therefore not recommended to be used for production usage. This requires to have camel-xml-jaxb on the classpath to be able [...]
| *camel.main.durationHitExitCode* | Sets the exit code for the application if duration was hit | | int
| *camel.main.durationMaxIdle{zwsp}Seconds* | To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. You can use this to run Camel for a short while. | | int
| *camel.main.durationMaxMessages* | To specify how many messages to process by Camel before automatic terminating the JVM. You can use this to run Camel for a short while. | | int