camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Burkard Stephan <>
Subject AW: MockEndpoint does not receive message if error occures in subroute
Date Wed, 03 Jan 2018 13:44:38 GMT
Thanks Quinn.

I knew that "global" onException clauses are only scoped to their RouteBuilder.

Follow-up question: Why are they not working for a subroute inside the same RouteBuilder?

Context for other readers: In the following example, the onException clause works fine for
the "direct:input" route, but not for the "direct:subroute" route. For the latter, the default
ErrorHandler is used.

public void configure() throws Exception {



                                   [do error handling]



                                   [do whatever needed]


                                   [do whatever needed]



                                   [do whatever needed]




-----Ursprüngliche Nachricht-----
Von: Quinn Stevenson []
Gesendet: Mittwoch, 20. Dezember 2017 20:41
Betreff: Re: MockEndpoint does not receive message if error occures in subroute

I’m not sure why this is working in the real world, but the reason the test is failing is
the default error handler is picking up the exception from the call to the direct://Validate
<direct://Validate> route.  If you add ".errorHandler(new NoErrorHandlerBuilder())”
to the direct://Validate <direct://Validate> route, your test will pass.

Quinn Stevenson<>

(801) 244-7758

> On Dec 1, 2017, at 6:07 AM, Burkard Stephan <<>>


> Hi Camel users


> I have attached a simplified example project (Maven) to illustrate a strange problem
I have in the tests of a current project.


> *** Setup ***

> - There is a Camel route that receives messages

> - It sends them to a validation subroute

> - The validation subroute uses a choice/when block to check a header

> value


> - If the header is ok, the message goes to the standard output

> endpoint

> - If the header is wrong, an exception is thrown and the error handler

> kicks in

> - The error handler sends the message to an alternative endpoint


> *** Problem ***

> If you open the project and run the route tests, you will see that one test fails.

> - It sends a message with the wrong header, so an exception is thrown

> - In the console output you can see that the error route processes the

> message (as expected) ==> But the error endpoint mock does not receive

> the message (WHY? This is wrong!)


> *** It works in real life ***

> - When I run the real project with the real endpoints, the error

> endpoint produces the messages

> - It is only in the test this does not work


> *** Strange effect ***

> When I move the choice/when block from the subroute to the main route,

> the test is successful


> Can anyone explain this? Is this a bug or am I doing/expecting something wrong?


> Thanks

> Stephan



> <>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message