You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Radoslaw Szymanek (Commented) (JIRA)" <ji...@apache.org> on 2012/04/13 14:25:16 UTC
[jira] [Commented] (CAMEL-5167) onException policy within global
context lost when error handler redefined within route context.
[ https://issues.apache.org/jira/browse/CAMEL-5167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13253317#comment-13253317 ]
Radoslaw Szymanek commented on CAMEL-5167:
------------------------------------------
Hi,
Sorry for being the pain in the ass, however your test case is not about the issue I wanted to raise.
Try changing your route in test into something like this :
{code}
from("direct:start")
.process(new Processor() {
private int counter;
public void process(Exchange exchange) throws Exception {
if (counter++ < 2) {
throw new IllegalArgumentException("Damn");
}
exchange.getIn().setBody("Bye World");
}
})
.errorHandler(defaultErrorHandler().maximumRedeliveries(2).redeliveryDelay(0))
.to("log:result")
.to("mock:result");
{code}
If you move errorHandler part after processor then your test case if failing.
I am reopening it only because you did not understand the mistake the user may make, which should be warned about.
> onException policy within global context lost when error handler redefined within route context.
> ------------------------------------------------------------------------------------------------
>
> Key: CAMEL-5167
> URL: https://issues.apache.org/jira/browse/CAMEL-5167
> Project: Camel
> Issue Type: Improvement
> Affects Versions: 2.9.1
> Reporter: Radoslaw Szymanek
> Assignee: Claus Ibsen
> Fix For: 2.10.0
>
>
> This may as well be Camel feature (limitation of Java DSL), but I found no indications/warning that this is a feature in Camel book or web documentation.
> The route is somewhat ill defined as local errorHandler should be placed before bean part, but maybe for those types of mistakes
> it should not have this nasty side effects of loosing global onException policy, but at least complain during route creation (?).
> Moreover, the route works properly if I remove global error handler, so it is rather nasty effect if route definition correctness depends on the existence of the global error handler definition.
> If I move local errorHandler before bean part then the my test passes as the onException policy is triggered and works properly.
> As soon as I redefine the error handler within a route the onException policy is no longer applicable for the route and the route propagates the exception back to the caller.
> {code}
> errorHandler(defaultErrorHandler().maximumRedeliveries(1));
> onException(NullPointerException.class).setOnRedelivery(new NullRegistrationDateProcessor());
> from("direct:toPropertyFile").routeId("registrationEntryToPropertyFile")
> .setHeader(Exchange.FILE_NAME, simple("${body.firstname}.${body.surname}"))
> .bean(RegistrationToPropertiesBean.class, "convert")
> // Potential bug in Camel, if the same error handler like global is turned on then onException defined in global context will not be picked up.
> .errorHandler(defaultErrorHandler().maximumRedeliveries(1))
> // the code above is working if no default handler was created for a global context.
> .to("file://" + outFolder);
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira