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-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 818c7cb6018 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.
818c7cb6018 is described below

commit 818c7cb60184dabaa3dc8ba7c1d38e2d1a6e868e
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon May 13 16:05:11 2024 +0200

    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.
---
 .../camel-debug-starter/src/main/docs/debug.json   |  2 +-
 .../boot/debug/CamelDebugAutoConfiguration.java    | 27 ++++++++++++++--------
 .../debug/CamelDebugConfigurationProperties.java   |  2 +-
 3 files changed, 19 insertions(+), 12 deletions(-)

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 8a6dfa969ed..fb29c30ae23 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 87d001aae49..8a0c8033430 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.component.debug.JmxConnectorService;
 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 @@ import org.springframework.context.annotation.Configuration;
 @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 @@ public class CamelDebugAutoConfiguration {
             @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 01368824225..03fda00fd62 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 @@ public class CamelDebugConfigurationProperties {
     /**
      * 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

Reply via email to