camel-idea-plugin icon indicating copy to clipboard operation
camel-idea-plugin copied to clipboard

Debugger - Support camel-jbang debugging

Open davsclaus opened this issue 3 years ago • 6 comments

You can run a java route such as

// camel-k: language=java

import org.apache.camel.builder.RouteBuilder;

public class hey extends RouteBuilder {
  @Override
  public void configure() throws Exception {

      // Write your routes here, for example:
      from("timer:java?period=1000")
        .routeId("java")
        .process(e -> {
           e.getMessage().setBody("Hej fra Java");
        })
        .to("log:info");
  }
}

And then run with

jbang --debug -Dcamel.jbang.version=3.15.0-SNAPSHOT CamelJBang@apache/camel run hey.java

And from IDEA (just open the hey.java) file, and do a remote JVM debugging on port 4004, and it works for java debugging inside the inlined processor.

But the Camel debugger does not work, such as a breakpoint at to("log:info")

This is Java, but would also be cool if you could do Camel debugging when using yaml or xml routes.

davsclaus avatar Jan 07 '22 09:01 davsclaus

Screenshot 2022-01-07 at 10 50 15

davsclaus avatar Jan 07 '22 09:01 davsclaus

The source locations are detected, but its in a single file named hey.java so its listed as

<routeLocations>
    <routeLocation routeId="java" id="java" index="0" sourceLocation="hey" sourceLineNumber="10"/>
    <routeLocation routeId="java" id="process1" index="1" sourceLocation="hey" sourceLineNumber="12"/>
    <routeLocation routeId="java" id="to1" index="2" sourceLocation="hey" sourceLineNumber="15"/>
</routeLocations>

davsclaus avatar Jan 07 '22 09:01 davsclaus

And dumping routes gives

<routes xmlns="http://camel.apache.org/schema/spring">
    <route customId="true" id="java" sourceLineNumber="10" sourceLocation="hey">
        <from sourceLineNumber="10" sourceLocation="hey" uri="timer:java?period=1000"/>
        <process id="process1" sourceLineNumber="12" sourceLocation="hey"/>
        <to id="to1" sourceLineNumber="15" sourceLocation="hey" uri="log:info"/>
    </route>
</routes>

davsclaus avatar Jan 07 '22 09:01 davsclaus

Yeah, remote debugging won't work because IDEA cannot detect the remote Java PID and connect via JMX...I'll see if there's a way around it.

javaduke avatar Jan 07 '22 14:01 javaduke

We can make camel-jbang write the pid to a file or something in case you can read this from the debugger plugin and fed that to IDEA or something

davsclaus avatar Jan 08 '22 08:01 davsclaus

I wonder if it's possible somehow to obtain the PID from the remote debugger agent. Let me investigate. I found very little, if any, documentation about how the remote debugger agent works, but maybe I was looking at the wrong places :)

javaduke avatar Jan 11 '22 19:01 javaduke

camel jbang stores the pid, in ~/.camel/NNNNN where NNNNN is the pid number.

davsclaus avatar Nov 21 '22 19:11 davsclaus