Return-Path: Delivered-To: apmail-activemq-camel-user-archive@locus.apache.org Received: (qmail 40182 invoked from network); 10 Aug 2007 15:07:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Aug 2007 15:07:19 -0000 Received: (qmail 6149 invoked by uid 500); 10 Aug 2007 15:07:18 -0000 Delivered-To: apmail-activemq-camel-user-archive@activemq.apache.org Received: (qmail 6098 invoked by uid 500); 10 Aug 2007 15:07:17 -0000 Mailing-List: contact camel-user-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-user@activemq.apache.org Delivered-To: mailing list camel-user@activemq.apache.org Received: (qmail 6089 invoked by uid 99); 10 Aug 2007 15:07:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 08:07:17 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of chirino@gmail.com designates 209.85.198.189 as permitted sender) Received: from [209.85.198.189] (HELO rv-out-0910.google.com) (209.85.198.189) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 15:07:11 +0000 Received: by rv-out-0910.google.com with SMTP id f1so568498rvb for ; Fri, 10 Aug 2007 08:06:51 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=AJfHLTXMfs6TavVwRAHstqQejYkS6OjJSGraKNvHaxmcPN6NJGhFtmvzeCz0dBWmtzhS+WChwRgg98Cp5P82kn95V2e7In5oMqL9rArlEK5POwGLyP/PwJscvsKnC0+IjslMX11QNzHpngxCZ2akt81KXy/dpMV28wwIlFIOh/o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=KRm8dBT5BqnXLJBzKG/5Uw8LlTBEVzqasbaoxGNnNDeRZYkPho4EJnRA+qAVsVf32lN2jC2l44KSVlAFDcVp++M74MOlsY0Cy4C0zPVg600DTqEQZteUrSmw3mETUEE7srH+mPTiuglejBeUcAIYOO901y1cZLeyhUSf51t+eNM= Received: by 10.114.161.11 with SMTP id j11mr2638595wae.1186758410745; Fri, 10 Aug 2007 08:06:50 -0700 (PDT) Received: by 10.114.160.20 with HTTP; Fri, 10 Aug 2007 08:06:50 -0700 (PDT) Message-ID: Date: Fri, 10 Aug 2007 11:06:50 -0400 From: "Hiram Chirino" Sender: chirino@gmail.com To: camel-user@activemq.apache.org Subject: Re: Exception based routing In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <12024679.post@talk.nabble.com> <12068759.post@talk.nabble.com> <12071407.post@talk.nabble.com> <12082262.post@talk.nabble.com> X-Google-Sender-Auth: 08bd739ea1286fc1 X-Virus-Checked: Checked by ClamAV on apache.org On 8/10/07, James Strachan wrote: > Here's a thought. The default error handler used in Camel is the > DeadLetterChannel; in an attempt to do what most people want out of > the box without having to explicitly customize things. > > So most errors tend to be transient system issues (e.g. database > deadlocks, temporary unavailability of connections/dependent > services), so retrying N times before sending to a dead letter channel > is a reasonable default. > > When a user customizes certain exceptions in a route; its often gonna > be a business exception or something similar. e.g. validation > exceptions (whether XSD or business logic constraint violations etc). > Usually for these cases, you don't want redelivery at all - since the > exception isn't gonna change as its business logic. > > So I was thinking, the default case should be that specifying an > exception handler route - without doing anything else - would > effectively by default, turn off retry for that exception, unless the > user explicitly customizes the retry count for that exception - or > maybe the user customizes the default value for all exception() > policies. > > e.g. > > exception(Validation.class).to("seda:badlyValidatedMessages"); > from("activemq:foo").to("jpa:MyEntityBean"); > > if we get a database exception, we retry N times. However by default > if we get a validation error we don't retry and just immediately send > to "seda:badlyValidatedMessages". > > If you don't want this, you can still be explicit... > > // lets retry for this exception... > exception(NullPointerException.class).maximumRetries(3); > > // otherwise lets not retry for validations... > exception(Validation.class).to("seda:badlyValidatedMessages"); > > from("activemq:foo").to("jpa:MyEntityBean"); > > Does that seem reasonable & non-confusing? Am a tad conscious of > adding too much magic under the covers - but in many ways conceptually > I kinda think when someone uses the code > > exception(that).to(somewhere); > > they are kinda saying 'on that exception, go to somewhere" - which > kinda implies there'd be no retry logic applied by default - unless > you explicitly say you want that. > This sounds good to me.. And a question I have.. will it be possible in 1 route builder to define a global exception handler for one set of routes and then change it to different one for a different set of routes. For example, if we want to keep each customer's messages on different jms queues: exception(Validation.class).to("activemq:cust-a-failures"); from("activemq:cust-a-po").to("seda:po"); from("activemq:cust-a-invoice").to("seda:invoice"); exception(Validation.class).to("activemq:cust-b-failures"); from("activemq:cust-b-po").to("seda:po"); from("activemq:cust-b-invoice").to("seda:nvoice"); > -- > James > ------- > http://macstrac.blogspot.com/ > -- Regards, Hiram Blog: http://hiramchirino.com