Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Camel 2.x - Debugger APIAvailable as of Camel 2.4 There is a new EnablingYou can enable the debugger from the BreakpointThere is a The breakpoint can be invoked in 2 kind of styles in Camel:
The processing is based on a The event is based on the There is a ConditionThere is a The condition can be invoked in 2 kind of styles in Camel:
Where there is a There is a ExampleFor example we can have this breakpoint breakpoint = new BreakpointSupport() { public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { String body = exchange.getIn().getBody(String.class); logs.add("Breakpoint at " + definition + " with body: " + body); } } In which we want to trigger when the message contains Camel. So we can create this camelCondition = new ConditionSupport() { public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { return body().contains("Camel").matches(exchange); } }; And to use this we just tell the public void testDebug() throws Exception { context.getDebugger().addBreakpoint(breakpoint, camelCondition); getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello Camel"); template.sendBody("direct:start", "Hello World"); template.sendBody("direct:start", "Hello Camel"); assertMockEndpointsSatisfied(); assertEquals(2, logs.size()); assertEquals("Breakpoint at To[log:foo] with body: Hello Camel", logs.get(0)); assertEquals("Breakpoint at To[mock:result] with body: Hello Camel", logs.get(1)); } Which then will only invoke the breakpoint callback for the Single stepIn the Java editor the debugger is capable of single stepping when a breakpoint is hit. The idea in Camel is that you want to single step an Exchange so you can step through how its routed and follow it from the 3rd party tooling. Only one single step active The Debugger only allows one active breakpoint during single step, which means that if you try to activate a 2nd single step, then it will disregarded. In this case the The context.getDebugger().addSingleStepBreakpoint(breakpoint); However what if you have multiple routes or the likes and only want to single step from route X, well you can just add a This beerCondition = new ConditionSupport() { public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { return "beer".equals(exchange.getFromRouteId()); } }; So you just provide the condition when adding the breakpoint: // we only want to single step the beer route context.getDebugger().addSingleStepBreakpoint(breakpoint, beerCondition); And the routes could be as follows: public void configure() throws Exception { // use debugger context.setDebugger(new DefaultDebugger()); from("direct:start").routeId("foo").to("log:foo").to("log:bar").to("mock:result"); from("direct:beer").routeId("beer").to("log:beer").to("mock:result"); } Which will cause the debugger to only single step when a message arrives on public void testDebug() throws Exception { // we only want to single step the beer route context.getDebugger().addSingleStepBreakpoint(breakpoint, beerCondition); getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Carlsberg"); template.sendBody("direct:start", "Hello World"); template.sendBody("direct:beer", "Carlsberg"); assertMockEndpointsSatisfied(); assertEquals(2, logs.size()); assertEquals("Single stepping at log:beer with body: Carlsberg", logs.get(0)); assertEquals("Single stepping at mock:result with body: Carlsberg", logs.get(1)); } |