camel-idea-plugin
camel-idea-plugin copied to clipboard
Debugger - Support camel-jbang debugging
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.
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>
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>
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.
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
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 :)
camel jbang stores the pid, in ~/.camel/NNNNN where NNNNN is the pid number.