This helped me understand that Camel Timer is defaulting to fixed-delay.

From the Camel code: 
https://github.com/Talend/apache-camel/blob/master/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
if (endpoint.isFixedRate()) { timer.scheduleAtFixedRate(task, 
endpoint.getDelay(), endpoint.getPeriod()); } // fixed-rate
else { timer.schedule(task, endpoint.getDelay(), endpoint.getPeriod()); } // 
fixed-delay

From the Javadoc: 
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Timer.html
In fixed-rate execution, each execution is scheduled relative to the scheduled 
execution time of the initial execution. Fixed-rate execution is appropriate 
for recurring activities that are sensitive to absolute time, such as ringing a 
chime every hour on the hour.
In fixed-delay execution, each execution is scheduled relative to the actual 
execution time of the previous execution. Fixed-delay execution is appropriate 
for recurring activities that require "smoothness."

Alex Mattern | AVP | Infomediary Architect | Investor Services

BROWN BROTHERS HARRIMAN
50 Post Office Square, Boston, MA 02110
T 617-772-0096 | M 857-283-3724 | alex.matt...@bbh.com
www.bbh.com

-----Original Message-----
From: Claus Ibsen <claus.ib...@gmail.com> 
Sent: Friday, August 5, 2022 3:21 AM
To: users@camel.apache.org
Subject: [EXTERNAL SENDER:] Re: Timer ensure that the route only runs once at a 
time

Hi

Do you mean only 1 run in total, then you can use repeatCount=1

The Timer is a JDK timer so it has fixed rate | fixed interval. So set 
fixedRate=true if you want to sleep 90000 between the runs, regardless for how 
long time a task takes.


On Fri, Aug 5, 2022 at 9:03 AM Simon Martinelli <si...@martinelli.ch> wrote:

> Hi,
>
> I use a timer:// and must make sure that the route only runs once even 
> if it takes longer than the period.
>
> I tried:
> fixedRate=false&period=90000
>
> But Camel starts a second route if the first run is not finished.
>
> Thanks,
> Simon
>


--
Claus Ibsen
-----------------
https://urldefense.com/v3/__http://davsclaus.com__;!!KV6Wb-o!871gYpwanej9QZN9tiw2SA3m2EAhS05sQmigyk3LW-09kWDl2fImnpPOiMfn45ziJ3CHW0H2SmouKMVThRtP$
  @davsclaus Camel in Action 2: 
https://urldefense.com/v3/__https://www.manning.com/ibsen2__;!!KV6Wb-o!871gYpwanej9QZN9tiw2SA3m2EAhS05sQmigyk3LW-09kWDl2fImnpPOiMfn45ziJ3CHW0H2SmouKGkIzbil$
 

*************************** IMPORTANT NOTE*****************************
The opinions expressed in this message and/or any attachments are those of the 
author and not necessarily those of Brown Brothers Harriman & Co., its 
subsidiaries and affiliates ("BBH"). There is no guarantee that this message is 
either private or confidential, and it may have been altered by unauthorized 
sources without your or our knowledge. Nothing in the message is capable or 
intended to create any legally binding obligations on either party and it is 
not intended to provide legal advice. BBH accepts no responsibility for loss or 
damage from its use, including damage from virus.
******************************************************************************

Reply via email to