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 79A2399D7 for ; Tue, 22 May 2012 10:01:17 +0000 (UTC) Received: (qmail 972 invoked by uid 500); 22 May 2012 10:01:15 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 174 invoked by uid 500); 22 May 2012 10:01:14 -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 99803 invoked by uid 99); 22 May 2012 10:01:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2012 10:01:11 +0000 X-ASF-Spam-Status: No, hits=1.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS,URI_HEX,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of raul@fusesource.com designates 74.125.245.76 as permitted sender) Received: from [74.125.245.76] (HELO na3sys010aog104.obsmtp.com) (74.125.245.76) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2012 10:01:06 +0000 Received: from mail-yw0-f49.google.com ([209.85.213.49]) (using TLSv1) by na3sys010aob104.postini.com ([74.125.244.12]) with SMTP ID DSNKT7tjzaEjADK6Qb/lS2huyL3PvhELP8r/@postini.com; Tue, 22 May 2012 03:00:46 PDT Received: by yhjj52 with SMTP id j52so6509286yhj.8 for ; Tue, 22 May 2012 03:00:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=L4CN2ZtBvL3rh6FB8uczOgv6+O1CuapsdT0nXKRMm6Q=; b=dGACSAwKKBIQSIPKHpUr6HCTORv5xj41dhPKzCp69elTC1wlm+KYy758MgfHRk00WR 9uCHGMcCRF2dbEKaIUawVe1L6cliLQkshF/saiQK0fz+F4Yvo5ZfxmbEBA5m+uZtjj2K PLQFVyj8mJTcn4L4WTL6kCJuAReFd+zHCE0CPobjhQWimSqhFoakPdWZ4WiUVjSl/ocX B1ub9KKCclbaPewDBYV/HF8bqw/bfjiGHYZgsOMGPNC8+tA9iTjju3xgAiuTHhqbjWtp wOdsBBpaqFX4BP25oj5dGvRSAmKH1BeRdQUU/dEhJcKQKUh72lEF2dRuEbYQ/H39n5Ca 2j6Q== Received: by 10.68.228.170 with SMTP id sj10mr10343784pbc.106.1337680844838; Tue, 22 May 2012 03:00:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.143.161.11 with HTTP; Tue, 22 May 2012 03:00:14 -0700 (PDT) In-Reply-To: <1337634818699-5713181.post@n5.nabble.com> References: <1337278616469-5711530.post@n5.nabble.com> <1337634818699-5713181.post@n5.nabble.com> From: Raul Kripalani Date: Tue, 22 May 2012 11:00:14 +0100 Message-ID: Subject: Re: Best practice to parse JSON response and retry if error To: users@camel.apache.org Content-Type: multipart/alternative; boundary=047d7b2ed3579456f304c09d1783 X-Gm-Message-State: ALoCoQmphfw1BT3eKgIIO/Z7AsatY9IqnKbyKUr30LuxdSLBG6r2P1sAVR0WlVZR1ZXKj9dWxosy X-Virus-Checked: Checked by ClamAV on apache.org --047d7b2ed3579456f304c09d1783 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Have you tried encapsulating both the HTTP invocation + the JSON unmarshalling behind a direct: endpoint? i.e. from("direct:doHttpInvocation") .to("http://localhost:8088/?cmd=3Dls%20/tmp/unlock") .unmarshal().json(JsonLibrary.Jackson, ShellResponse.class); The default error handler in this new route (DefaultErrorHandler) will immediately return the exception to the caller. >From the parent route, you invoke the direct endpoint using: .to("direct:doHttpInvocation"). Hence, the two operations become one from the viewpoint of the parent route, so it should now cycle over "direct:doHttpInvocation" for redeliveries. Let us know if that worked for you. Regards, *Ra=FAl Kripalani* Principal Consultant | FuseSource Corp. raul@fusesource.com | fusesource.com skype: raul.fuse | twitter: @raulvk , @fusenews On 21 May 2012 22:13, Nestor Urquiza wrote: > One way to solve this (successfully tested) would be using a bean > encapsulating all the logic (http request, unmarshalling, testing for > errors): > > //So we are probably better just building a bean that invokes the http > service, analyze the response and throws Exception if error > .setHeader("url", > constant("http://localhost:8088/cmd=3Dls%20/tmp/unlock > ")).bean(ShellBeanService.class) > > > I believe a nice feature would be to allow to go to a particular point in > the case of a failure. I am unsure how to achieve that though. > > I would appreciate any feedback on this. > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Best-practice-to-parse-JSON-response-an= d-retry-if-error-tp5711530p5713181.html > Sent from the Camel - Users mailing list archive at Nabble.com. > --047d7b2ed3579456f304c09d1783--