Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 51C59E197 for ; Wed, 19 Dec 2012 21:10:04 +0000 (UTC) Received: (qmail 63859 invoked by uid 500); 19 Dec 2012 21:10:03 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 63815 invoked by uid 500); 19 Dec 2012 21:10:03 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 63807 invoked by uid 99); 19 Dec 2012 21:10:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 21:10:03 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of christian.mueller@gmail.com designates 209.85.219.48 as permitted sender) Received: from [209.85.219.48] (HELO mail-oa0-f48.google.com) (209.85.219.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 21:09:59 +0000 Received: by mail-oa0-f48.google.com with SMTP id h2so2596841oag.21 for ; Wed, 19 Dec 2012 13:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=pz27K7SqvmH5rovwjB03WlYSLWqdW5y8qj7vOSWboFo=; b=N2tu3gRnYOOaoNHJE4cXjwmvvXYbg+jGyHyDDbsFQrXvk8Qk5q6OVMxsGBz8xRt7nQ 6zmCJD2mZ8Asej4cph/JZMEO0ohjRwbLUyFVCLmy5wF7AkAULDIsL9DZ9MZPKrwN+zZl SxH7fgs8SY+TC2tUxeaGUzKxKYmOxvG8lupSc+e/K72ib5yZzwimrxRsBNuN/Z/qUHd2 EuePv86vXVGpDGXrrem0O5SFskBx5hBTKOsN6E+p3Fk/6nKWXQkGVeg1bwalSrHUAECI IAIU2srAQ35x1ATJyzmuYTZLyKTmGCVvS2360iihmw4OYFNqL2cEWsHPIsqxbRBLF1rP H/Xg== MIME-Version: 1.0 Received: by 10.182.162.66 with SMTP id xy2mr5984307obb.82.1355951378911; Wed, 19 Dec 2012 13:09:38 -0800 (PST) Received: by 10.182.114.103 with HTTP; Wed, 19 Dec 2012 13:09:38 -0800 (PST) In-Reply-To: <1355940303884-5724392.post@n5.nabble.com> References: <1355853294502-5724296.post@n5.nabble.com> <1355853477368-5724298.post@n5.nabble.com> <1355859100211-5724306.post@n5.nabble.com> <1355865473773-5724320.post@n5.nabble.com> <1355940303884-5724392.post@n5.nabble.com> Date: Wed, 19 Dec 2012 22:09:38 +0100 Message-ID: Subject: Re: global onException only works for first to() route item but nothing after that From: =?ISO-8859-1?Q?Christian_M=FCller?= To: users@camel.apache.org Content-Type: multipart/alternative; boundary=e89a8f839dfb45d2f704d13b08d9 X-Virus-Checked: Checked by ClamAV on apache.org --e89a8f839dfb45d2f704d13b08d9 Content-Type: text/plain; charset=ISO-8859-1 I updated this example for you (you don't have to use inner classes, but it's easier to share...): import org.apache.camel.CamelExecutionException; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; public class CamelGlobalOnExceptionTest extends CamelTestSupport { @Test public void test() throws Exception { MockEndpoint mockErrorHandler = ((MockEndpoint) context.getEndpoint("mock:errorHandler")); mockErrorHandler.expectedMessageCount(1); MockEndpoint mockEnd = ((MockEndpoint) context.getEndpoint("mock:end")); mockEnd.setSleepForEmptyTest(2000); mockEnd.expectedMessageCount(0); try { template.sendBody("direct:start", "Camel"); fail("CamelExecutionException expected"); } catch (CamelExecutionException e) { // expected } mockErrorHandler.assertIsSatisfied(); } @Override protected JndiRegistry createRegistry() throws Exception { JndiRegistry registry = super.createRegistry(); registry.bind("bean1", new MyBean(false)); registry.bind("bean2", new MyBean(true)); return registry; } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new MyRouteBuilder(); } public static class MyRouteBuilder extends RouteBuilder { public void configure() throws Exception { getContext().setTracing(true); onException(Exception.class) .handled(false) .to("mock:errorHandler") .logStackTrace(true); from("direct:start") .to("bean:bean1") .to("bean:bean2") .to("mock:end"); } } public static class MyBean { private boolean shouldThrowAnException; public MyBean(boolean shouldThrowAnException) { this.shouldThrowAnException = shouldThrowAnException; } public void process(Exchange exchange) throws Exception { if (shouldThrowAnException) { throw new Exception("exception forced for unit test"); } } } } and use the following log4j.properties file: log4j.rootLogger=INFO, file, out # CONSOLE appender not used by default log4j.appender.out=org.apache.log4j.ConsoleAppender log4j.appender.out.layout=org.apache.log4j.PatternLayout log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n # File appender log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n log4j.appender.file.file=target/test.log log4j.appender.file.append=true and got the following log entries: 2012-12-19 22:05:39,311 [main ] INFO Tracer - ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-2 >>> (route1) from(direct://start) --> bean://bean1 <<< Pattern:InOnly, Headers:{breadcrumbId=ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-1}, BodyType:String, Body:Camel 2012-12-19 22:05:39,332 [main ] INFO LazyLoadingTypeConverter - Loaded additional 0 type converters (total 169 type converters) in 0.001 seconds 2012-12-19 22:05:39,336 [main ] INFO Tracer - ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-2 >>> (route1) bean://bean1 --> bean://bean2 <<< Pattern:InOnly, Headers:{breadcrumbId=ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-1}, BodyType:String, Body:Camel 2012-12-19 22:05:39,338 [main ] INFO Tracer - ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-2 >>> (route1) bean://bean2 --> OnException[Exception] <<< Pattern:InOnly, Headers:{breadcrumbId=ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-1, CamelRedeliveryCounter=0, CamelRedelivered=false}, BodyType:String, Body:Camel 2012-12-19 22:05:39,338 [main ] INFO Tracer - ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-2 >>> OnException[Exception] --> mock://errorHandler <<< Pattern:InOnly, Headers:{breadcrumbId=ID-Christian-Muellers-MacBook-Pro-local-55586-1355951138794-0-1, CamelRedeliveryCounter=0, CamelRedelivered=false}, BodyType:String, Body:Camel This should also work for you... Best, Christian On Wed, Dec 19, 2012 at 7:05 PM, semiosis wrote: > Hi Christian, > > I am using the Java DSL, overriding the configure() method in a subclass of > SpringRouteBuilder. I added this line to my configure() method, also to > the > configure() method in the test case you sent me... > > getContext().setTracing(true) > > and added some explicit log4j info messages to the code to verify logging > is > working. All i see are my own messages, nothing from camel. > > To recap, my problem is that I am having trouble with exception handling > after the first bean in my route. I want to trace execution so that I can > figure out where that exception is going when it is silently dropped. But > I > can't get tracing to work even in the simple test case. > > Thanks again for all the help, > > -louis > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/global-onException-only-works-for-first-to-route-item-but-nothing-after-that-tp5724296p5724392.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- --e89a8f839dfb45d2f704d13b08d9--