Details
Description
Run the following route, the onException handler would be executed twice. The counter will be 2.
int counter = 0
from("timer://testRoute2?repeatCount=1").routeId('testRoute_timer2').autoStartup(true)
.onException(IllegalArgumentException).onWhen({it.getException().toString().contains('foo')})
.process(Unknown macro: { counter++ println "print in onException foo $counter" }).handled(false)
.end()
.log('in testRoute2')
.process(Unknown macro: { println 'before throwing exception' throw new IllegalArgumentException("foo") })
This would generate the following:
2024-07-19 17:46:11.711 [Camel (camel-1) thread #31 - timer://testRoute2] testRoute_timer2 - in testRoute2
before throwing exception
print in onException foo 1
print in onException foo 2
If the handled(true) is used, the handler would only run once.