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 178BC1892E for ; Mon, 11 Jan 2016 02:12:31 +0000 (UTC) Received: (qmail 17105 invoked by uid 500); 11 Jan 2016 02:12:30 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 17055 invoked by uid 500); 11 Jan 2016 02:12:30 -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 17041 invoked by uid 99); 11 Jan 2016 02:12:30 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2016 02:12:30 +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 C8F44180047 for ; Mon, 11 Jan 2016 02:12:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.212 X-Spam-Level: **** X-Spam-Status: No, score=4.212 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id cM2HpWtak68H for ; Mon, 11 Jan 2016 02:12:23 +0000 (UTC) Received: from mail-ig0-f176.google.com (mail-ig0-f176.google.com [209.85.213.176]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id B1D3343BFE for ; Mon, 11 Jan 2016 02:12:22 +0000 (UTC) Received: by mail-ig0-f176.google.com with SMTP id mw1so103113421igb.1 for ; Sun, 10 Jan 2016 18:12:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=g7wyugDOEf3YWnHPI5jI6Vm3eT9OJC804MgfcdCdAvk=; b=kDdUQWJCjgzdXhDhAwMMpjPV8JWZNBH6ppKCwDIaDD01Jq0R9qOed9Jkl4UMj1DAmX vhJlpXq++mZ4xJ7HmFUTlic23IEgOo1awU8wxs3utKCvqa9VDgiRMyKTYaIyxa/fvfGW HTPso+kL3BiRhephvCF0cvXTNvCpybl7/3Ls0jWggcn/Fq0/oLLqPBPNmeCvKCfDEN4a F/hBe0SWwT6S41rKshc69FL0w/mjnj8JhANiz01U/y9KY3G8WwN4mCsQoO2kbgZXwZyY vX8RSr7q4AAlMCPJkWewajZFAuzEhBDSQenFVBpHMApCMwH+1VEqmyz2A3RTjbB6n2Q8 I1dQ== MIME-Version: 1.0 X-Received: by 10.50.41.68 with SMTP id d4mr9520553igl.79.1452478342092; Sun, 10 Jan 2016 18:12:22 -0800 (PST) Received: by 10.36.215.5 with HTTP; Sun, 10 Jan 2016 18:12:22 -0800 (PST) In-Reply-To: <1452260835234-5776017.post@n5.nabble.com> References: <1452260835234-5776017.post@n5.nabble.com> Date: Mon, 11 Jan 2016 07:42:22 +0530 Message-ID: Subject: Re: timer reschedule / loop between routes From: Ravindra Godbole To: users@camel.apache.org Content-Type: multipart/alternative; boundary=089e011768e79fe11105290577a2 --089e011768e79fe11105290577a2 Content-Type: text/plain; charset=UTF-8 Can you maintain a persistent state for directcaller ? If you can do that .... 1. Timer always executes at predefined interval [ 1 sec or whatever 2. direct:apiCaller maintains a state STARTED, INPROGRESS, FINISHED. 3. if next call from timer sees that state is INPROGRESS then nothing happens. If it is FINISHED then new execution started. -Ravi On Fri, Jan 8, 2016 at 7:17 PM, zappee wrote: > Hi, > > I am new in Apache Camel and have an interesting scenario. Could you please > help me? > > My current route looks like this: > (1) mainRoute > timer://xxx?period=10000, to: "direct:apiCaller" > (2) apiCaller > retrieve data from restapi, to: "direct:persistData" > (3) persistData > save data to database > > So every x second a restapi is called and the received data is persisted. > It > works fine. But I need to call the restapi continuously until it receives > an > empty answer in the rest response so I need to do a loop with (2) and (3) > steps. And then if there is no more data at moment then have to wait till > the next timer event is fired to start downloading the newcomer data if we > have. > > So my route needs to do this: > (1) route1 > timer://xxx?period=10000, to: "direct:apiCaller" > --> do > (2) apiCaller > retrieve data from restapi, to: "direct:persistData" > (3) persistData > save data to database > --> while (answer of restapi is empty) > > My first idea was to reschedule the timer from 1 minutes to 1 sec in case > of > I have more data to download. And when we do not have more data to download > then reschedule my timer from 1 sec to 1 min just because of wait till a > little bit. > > But I am not able to reschedule the timer runntime so it needs to be some > different solution to handle my use case. > > What is the best way to reach my target? > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/timer-reschedule-loop-between-routes-tp5776017.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- - Ravi *[ View My Youtube Channel ] * Phone: +91 *98 509 760 91* --089e011768e79fe11105290577a2--