...
The Debugger allows tooling or the likes to attach breakpoints which is being invoked when Exchanges is are being routed.
Default implementation
Camel provides a default implementation org.apache.camel.impl.DefaultDebugger
which you can set on the CamelContext
using the setDebugger
method.
Likewise you can get hold of the Debugger using the getDebugger
method on CamelContext
.
The org.apache.camel.spi.Debugger
has methods to attach and remove breakpoints. And to suspend/resume all breakpoints etc.
You can also attach a condition to the breakpoint so it only reacts if the condition matches.
...
If you are developing unit tests using the camel-test
component, then the Debugger comes out of the box.
From Camel 2.9 onwards : you would need to explicit enable the debugger, by overriding isUseDebugger()
method and return true
.
Example
In this unit test
...
We want to debug the following route:
Wiki Markup |
---|
{snippet:id=e2|lang=java|url=camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugTest.java} |
debugBefore
method as shown:Wiki Markup |
---|
{snippet:id=e1|lang=java|url=camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugTest.java} |
debugBefore
method. Then fire up the unit test and wait for the Java editor to hit the breakpoint. Then you can inspect the Exchange during debugging while it advances during routing. The ProcessorDefinition
and the id
and shortName
parameters is all information which tells you where in the route the breakpoint was hit.Tip |
---|
There is also a |
The screenshot below shows the Debugger in action. The IDE (IDEA) has hit the breakpoint and we can inspect the parameters.
Notice how we can see that the message is to be send to the "the mock:a
" endpoint.: