CAMEL-20758: camel-debug-starter - Should be created sooner so the debugger is configured before routes is created. Also turn on debug by default if you have camel-debug-starter on the classpath.
diff --git a/components-starter/camel-debug-starter/src/main/docs/debug.json b/components-starter/camel-debug-starter/src/main/docs/debug.json
index 8a6dfa9..fb29c30 100644
--- a/components-starter/camel-debug-starter/src/main/docs/debug.json
+++ b/components-starter/camel-debug-starter/src/main/docs/debug.json
@@ -39,7 +39,7 @@
       "type": "java.lang.Boolean",
       "description": "Enables Debugger in your Camel application.",
       "sourceType": "org.apache.camel.spring.boot.debug.CamelDebugConfigurationProperties",
-      "defaultValue": false
+      "defaultValue": true
     },
     {
       "name": "camel.debug.fallback-timeout",
diff --git a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java
index 87d001a..8a0c803 100644
--- a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java
+++ b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java
@@ -21,8 +21,10 @@
 import org.apache.camel.impl.debugger.DefaultBacklogDebugger;
 import org.apache.camel.spi.BacklogDebugger;
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.CamelSpringBootApplicationListener;
 import org.apache.camel.support.LifecycleStrategySupport;
 import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
@@ -32,23 +34,24 @@
 @ConditionalOnBean(CamelAutoConfiguration.class)
 @EnableConfigurationProperties(CamelDebugConfigurationProperties.class)
 @AutoConfigureAfter(CamelAutoConfiguration.class)
+@AutoConfigureBefore(CamelSpringBootApplicationListener.class)
 public class CamelDebugAutoConfiguration {
 
     @Bean
     public BacklogDebugger backlogDebugger(CamelContext camelContext, CamelDebugConfigurationProperties config)
             throws Exception {
 
-        if (!config.isEnabled() && !config.isStandby()) {
-            return null;
-        }
-
-        // must enable source location so debugger tooling knows to map breakpoints to source code
-        camelContext.setSourceLocationEnabled(true);
-
         // enable debugger on camel
         camelContext.setDebugging(config.isEnabled());
         camelContext.setDebugStandby(config.isStandby());
 
+        if (config.isEnabled() || config.isStandby()) {
+            // must enable source location and history
+            // so debugger tooling knows to map breakpoints to source code
+            camelContext.setSourceLocationEnabled(true);
+            camelContext.setMessageHistory(true);
+        }
+
         BacklogDebugger debugger = DefaultBacklogDebugger.createDebugger(camelContext);
         debugger.setStandby(config.isStandby());
         debugger.setInitialBreakpoints(config.getBreakpoints());
@@ -68,19 +71,23 @@
             @Override
             public void onContextStarted(CamelContext context) {
                 // only enable debugger if not in standby mode
-                if (!debugger.isStandby()) {
+                if (config.isEnabled() && !debugger.isStandby()) {
                     debugger.enableDebugger();
                 }
             }
 
             @Override
             public void onContextStopping(CamelContext context) {
-                debugger.disableDebugger();
+                if (debugger.isEnabled()) {
+                    debugger.disableDebugger();
+                }
             }
         });
 
         // to make debugging possible for tooling we need to make it possible to do remote JMX connection
-        camelContext.addService(new JmxConnectorService());
+        if (config.isEnabled() || config.isStandby()) {
+            camelContext.addService(new JmxConnectorService());
+        }
 
         camelContext.addService(debugger);
 
diff --git a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java
index 0136882..03fda00 100644
--- a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java
+++ b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java
@@ -26,7 +26,7 @@
     /**
      * Enables Debugger in your Camel application.
      */
-    private boolean enabled;
+    private boolean enabled = true;
 
     /**
      * To set the debugger in standby mode, where the debugger will be installed by not automatic enabled. The debugger