On Thu, Sep 13, 2012 at 11:34 AM, Andreas Jacobsen <andr...@andreasjacobsen.com> wrote: > That doesn't match my experiences. I've stepped through the > DefaultExceptionPolicyStrategy and global scope is definitely global > in Java DSL routebuilders too. I wish the documentation were more > clear on what the expected behavior should be. > > I've created CAMEL-5456[0] because I thought it was meant to be > routebuilder-scoped, but if it's actually global to the camelcontext, > I'm very unhappy with the implementation. > > Perhaps a dev could chime in and clarify the intent and suggested use? > The pattern Claus suggested works fine until you start using more > complex setups… > > [0]: https://issues.apache.org/jira/browse/CAMEL-5456 >
I finally got some time to help with this, and have fixed the issue reported. I also updated the error handler docs to better reflect the scopes for Java DSL vs XML DSLs. http://camel.apache.org/error-handling-in-camel.html > On 11 September 2012 22:17, Mitko Kolev <me2...@gmail.com> wrote: >> Hi, >> >> the "global" scope mentioned here >> http://camel.apache.org/exception-clause.html in this case actually means >> "route builder" scope. >> For example the rule for ValidationException will trigger for both routes >> in the same route builder (at least with the Camel version 2.6.x with which >> I did the test to find this out some months ago) >> >> configure(){ >> ... >> onException(ValidationException.class). >> to("activemq:validationFailed"); >> >> from("seda:inputA"). >> to("validation:foo/bar.xsd", "activemq:someQueue"); >> >> from("seda:inputB").to("direct:foo"). >> to("rnc:mySchema.rnc", "activemq:anotherQueue"); >> } >> >> However, if you split this in 2 route builders like this >> >> configure(){ >> ... >> onException(ValidationException.class). >> to("activemq:validationFailed"); >> >> from("seda:inputB").to("direct:foo"). >> to("rnc:mySchema.rnc", "activemq:anotherQueue"); >> } >> >> & >> >> configure(){ >> ... >> from("seda:inputB").to("direct:foo"). >> to("rnc:mySchema.rnc", "activemq:anotherQueue"); >> } >> >> the onException will not process ValidationExceptions from the second route >> ("seda:inputB"). In this sense the onException clause is not context >> scoped, but rather route builder scoped. >> >> I guess the confusion comes from the Sping DSL format, as the onException >> clause is within the camelContext tag, so you might think the onException >> definition is "camel context" scoped (configuration of the camel context). >> >> >> Regards, >> Mitko >> >> On Tue, Sep 11, 2012 at 6:14 PM, Andreas Jacobsen < >> andr...@andreasjacobsen.com> wrote: >> >>> My understanding is that exception policies defined in global scope >>> are actually global. You could set up a seperate routebuilder >>> specifically for the global exception policies. >>> >>> Claus's suggestion works too, since the same exception policies will >>> be created several times. >>> >>> On 11 September 2012 16:26, vishal1981 <vishal.changr...@ericsson.com> >>> wrote: >>> > Alright thanks. >>> > But then global scope doesn't really means global to the camelcontext. >>> Its >>> > global to the routes currently being defined. >>> > Thanks for your help >>> > >>> > >>> > >>> > -- >>> > View this message in context: >>> http://camel.465427.n5.nabble.com/Global-exception-policy-across-Route-builder-configure-methods-tp5719075p5719131.html >>> > Sent from the Camel - Users mailing list archive at Nabble.com. >>> -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen