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 D44CB196DE for ; Fri, 22 Apr 2016 13:29:08 +0000 (UTC) Received: (qmail 1814 invoked by uid 500); 22 Apr 2016 13:29:08 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 1764 invoked by uid 500); 22 Apr 2016 13:29:08 -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 1753 invoked by uid 99); 22 Apr 2016 13:29:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Apr 2016 13:29:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id AAC1718053D for ; Fri, 22 Apr 2016 13:29:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 5.486 X-Spam-Level: ***** X-Spam-Status: No, score=5.486 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, HTML_MESSAGE=2, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_SOFTFAIL=0.972, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id mffsonJimSSp for ; Fri, 22 Apr 2016 13:29:05 +0000 (UTC) Received: from mbob.nabble.com (mbob.nabble.com [162.253.133.15]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 4CE175F47B for ; Fri, 22 Apr 2016 13:29:05 +0000 (UTC) Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id 3C07B25E682E for ; Fri, 22 Apr 2016 06:15:20 -0700 (PDT) Date: Fri, 22 Apr 2016 06:29:04 -0700 (MST) From: bocamel To: users@camel.apache.org Message-ID: In-Reply-To: References: <1459523575909-5780262.post@n5.nabble.com> <1D0CE833-F2C0-4406-A4B1-A3C90D702DAC@gmail.com> <1459700902650-5780374.post@n5.nabble.com> <1461265783330-5781499.post@n5.nabble.com> Subject: RE: How to return early from a direct: subroute? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_435683_597966412.1461331744600" ------=_Part_435683_597966412.1461331744600 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Ranx, After giving it more thoughts, I think your suggestion of throwing exception is a neat solution. Using a route level OnException to catch and handle the exception, then quietly return to the caller of the direct route. I will give it a try. But there are situations where I need to disable error-handling at route level - for example, to force the retry to start in the parent route. So the throwing exception approach might not work for those situations. Thanks for the example on processor chain. I will play with it. Thanks! From: Ranx [via Camel] [mailto:ml-node+s465427n5781523h91@n5.nabble.com] Sent: Thursday, April 21, 2016 11:53 PM To: bocamel Subject: Re: How to return early from a direct: subroute? Is there a reason you don't want to throw an exception? If you have multiple processors in a row like that all of which might throw exceptions that certainly seems reasonable. The other possibility here is to inject your processors into one another in a chain of responsibility. I usually use a chain of Pojos if I need that but it would be similar. Don't copy this as I'm writing it in plain text after a long day flying and it's not coming out of an IDE. Plus I never use Processors/Exchanges and use blueprint so don't know if the XML would match what you're after. But you get the idea. public class MyProcessor implements Processor { Processor nextProcessor; //put in getters/setters public void process(Exchange exchange) throws Exception { // do something... //if logic is correct then call next processor otherwise return. nextProcessor.process(exchange); } } etc. On Thu, Apr 21, 2016 at 2:09 PM, bocamel <[hidden email]> wrote: > Thank you all very much for responding to my question and for offering > solutions. I have implemented my application using a combination of > headers > and . But I also concluded that there is not a simple and elegant > way to do what I intended to do. I wish the great Camel team will add such > a feature in a future release. > > > > Add a new property header in Exchange: ROUTE_RETURN > > When processing an exchange in a direct route, if this property is true, > then Camel will stop propagating this exchange through the rest of the > direct route and return the exchange back to the caller of the direct > route. > It is the responsibility of the user who sets this property to set the > camel > message body/headers so that the caller of the direct route can continue to > process it. > > The exception/error handling can stay the same, i.e. they do not need to > check this property. > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/How-to-return-early-from-a-direct-subroute -tp5780262p5781499.html > Sent from the Camel - Users mailing list archive at Nabble.com. > _____ If you reply to this email, your message will be added to the discussion below: http://camel.465427.n5.nabble.com/How-to-return-early-from-a-direct-subroute -tp5780262p5781523.html To unsubscribe from How to return early from a direct: subroute?, click here . NAML -- View this message in context: http://camel.465427.n5.nabble.com/How-to-return-early-from-a-direct-subroute-tp5780262p5781560.html Sent from the Camel - Users mailing list archive at Nabble.com. ------=_Part_435683_597966412.1461331744600--