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 596DD7F73 for ; Tue, 2 Aug 2011 01:03:52 +0000 (UTC) Received: (qmail 66312 invoked by uid 500); 2 Aug 2011 01:03:51 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 66200 invoked by uid 500); 2 Aug 2011 01:03:51 -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 66183 invoked by uid 99); 2 Aug 2011 01:03:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Aug 2011 01:03:50 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of willem.jiang@gmail.com designates 209.85.210.49 as permitted sender) Received: from [209.85.210.49] (HELO mail-pz0-f49.google.com) (209.85.210.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Aug 2011 01:03:44 +0000 Received: by pzk33 with SMTP id 33so13043952pzk.36 for ; Mon, 01 Aug 2011 18:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=B5QZzqkZKiIwrrHzQic0CK9i6lSXYzeDugheZMcH53U=; b=lDHqwNQNWS7Ya0Bc1wVc/Ps63zQ6AcSeA/+MPWH+lfhOJUPQAlur6m8pmMb98Qpr6Z lD2b/wcYufQP6oqYzximgGXF3puDyGL+cddJTt4rJSTuqVcSwYbiTJKUXoJp3bNFnHeI PfGPYQO2z6LprlYJBk6ut9JjIeirA8rRPEWHw= Received: by 10.68.31.39 with SMTP id x7mr9422466pbh.226.1312247002638; Mon, 01 Aug 2011 18:03:22 -0700 (PDT) Received: from [192.168.0.158] ([125.34.8.89]) by mx.google.com with ESMTPS id o6sm1651478pbj.34.2011.08.01.18.03.19 (version=SSLv3 cipher=OTHER); Mon, 01 Aug 2011 18:03:21 -0700 (PDT) Message-ID: <4E374CD5.7040200@gmail.com> Date: Tue, 02 Aug 2011 09:03:17 +0800 From: Willem Jiang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: users@camel.apache.org Subject: Re: Route does not shut down if there is no message on poll. References: <1311960633885-476108.post@n5.nabble.com> <1311960633884-476111.post@n5.nabble.com> <1311960633883-4647763.post@n5.nabble.com> <1312198431307-4654806.post@n5.nabble.com> In-Reply-To: <1312198431307-4654806.post@n5.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, Can you check the timedroute route states ? CronScheduledRoutePolicy start or resume the route when the route status is ready. ServiceStatus routeStatus = route.getRouteContext().getCamelContext().getRouteStatus(route.getId()); if (action == Action.START) { if (routeStatus == ServiceStatus.Stopped) { startRoute(route); } else if (routeStatus == ServiceStatus.Suspended) { startConsumer(route.getConsumer()); } } Willem On 8/1/11 7:33 PM, cwhistler wrote: > I think I have this worked out now. I found the PollingConsumerPollStrategy > interface so I created an EmptyPollStrategy class. I changed the begin() > method to simply return true. In the commit() method I checked the > numberPolled parameter and if it is 0 then I just stop the consumer. I left > the rollback() method unchanged. > > public boolean begin(Consumer consumer, Endpoint endpoint) > { > return true; > } > > public void commit(Consumer consumer, Endpoint endpoint, int numberPolled) > { > if (numberPolled == 0) > { > try > { > consumer.stop(); > } > catch(Exception e) > { > e.printStackTrace(); > } > } > } > > public boolean rollback(Consumer arg0, Endpoint arg1, int arg2, Exception > arg3) throws Exception > { > // TODO Auto-generated method stub > return false; > } > > > OK so to run my route only at 9:35 every day I have setup the route as > follows. The references to the filters and processors are all wired up with > Spring. > > I created the StopRouteProcessor to stop the route when it has read all of > the files that were initially polled. > > The .noAutoStartup() seemed to be required as the route always started with > camel and then at the scheduled time. > > CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy(); > policy.setRouteStartTime("0 35 9 * * ?"); > > from("file://test/input?preMove=inprogress&pollStrategy=#emptyPollStrategy&delete=true&filter=#errorFileFilter") > .routePolicy(policy) > .noAutoStartup() > .routeId("timedroute") > .processRef("addHeadersProcessor") > .to("file://test/output") > .onCompletion().process(new StopRouteProcessor("timedroute").end() > ; > > The only problem I'm seeing now is when I have to schedule this route to run > more than once. So for example I want 9:35 and then again at 11:35. By > letting Spring wire up the EmptyPollStrategy, it is only effective with the > first scheduled execution. It never runs on the 2nd schedule. > > -- > View this message in context: http://camel.465427.n5.nabble.com/Route-does-not-shut-down-if-there-is-no-message-on-poll-tp476108p4654806.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Willem ---------------------------------- FuseSource Web: http://www.fusesource.com Blog: http://willemjiang.blogspot.com (English) http://jnn.javaeye.com (Chinese) Twitter: willemjiang Weibo: willemjiang