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 9868FFEE5 for ; Wed, 8 May 2013 21:16:03 +0000 (UTC) Received: (qmail 81088 invoked by uid 500); 8 May 2013 21:16:03 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 80993 invoked by uid 500); 8 May 2013 21:16:02 -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 80983 invoked by uid 99); 8 May 2013 21:16:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 May 2013 21:16:02 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: encountered temporary error during SPF processing of domain of shyenuganti@gmail.com) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 May 2013 21:15:58 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1UaBhl-0007oE-Gd for users@camel.apache.org; Wed, 08 May 2013 14:15:17 -0700 Date: Wed, 8 May 2013 14:15:17 -0700 (PDT) From: shyenuganti To: users@camel.apache.org Message-ID: <1368047717495-5732200.post@n5.nabble.com> Subject: Issue with using onException() MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi All, Here is my route. The goal I am trying to achieve is to send a STATUS (0=success, 1= failure) back to the caller. It works for a successful execution. I am returning a 0 from the onCompletion(). When the route fails at the ".unmarshal(beanIO)" step I need to stop processing the route any further, and reply back with a 0 to the consumer on "direct:routeStatus". But, As of now, the route does not stop on exception as it is handled it in doCatch(). How can I stop the route here and send a response back? Currently it gives me an error saying "no consumers present on direct:routeStatus". Why is this a problem when it was working for the success scenario? Does the onCompletion() execute even on exception cases? When I try to use one single try catch(), It is giving me an error saying ChoiceDefinition do not support doCatch(). Why is it so ? onException(Exception.class).handled(true).maximumRedeliveries(0) .setBody(constant(1)) .log("Returning Status of the route: ${body}") .to("direct:routeStatus"); from(getDirectEndPoint()).routeId(getRouteId()) .onCompletion() .setBody(constant(0)).to("direct:routeStatus") .end() .pollEnrich(getFileEndPoint()) .beanRef("loggingBean", "logDebug(${id}, '"+this.getClass().getName()+"', 'Reading Flat File')") .doTry() .unmarshal(beanIO) .doCatch(Throwable.class) .beanRef("loggingBean", "endError(${id}, '"+this.getClass().getName()+"', ${exception}, 'Exception while Unmarshalling File : ${header.CamelFileName} ')") .end() .split(body()) .choice() .when(transactionRecord) .choice() .when(UNDERNOTICE_OR_RESCISSION) .doTry() .bean(PolicyStatusRequestHelper.class,"getStatusRequest") .marshal().json() .inOut(getJmsEndPoint()) .beanRef("loggingBean", "logDebug( ${id}, '"+this.getClass().getName()+"', 'Transaction Status :"+ simple("${body}") +"')") .doCatch(Throwable.class) .beanRef("loggingBean", "endError(${id}, '"+this.getClass().getName()+"', ${exception}, 'Exception while sending StatusRequest to JMS queue')") .end(); How can I properly use onException() in my above route to achieve the same? I tried putting it at different places. But nothing seems to work. I am not able to propagate the exception properly. Can anyone really help with this? THanks ! -- View this message in context: http://camel.465427.n5.nabble.com/Issue-with-using-onException-tp5732200.html Sent from the Camel - Users mailing list archive at Nabble.com.