You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Simon Martinelli <si...@martinelli.ch> on 2022/08/05 07:03:25 UTC

Timer ensure that the route only runs once at a time

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

AW: Timer ensure that the route only runs once at a time

Posted by Simon Martinelli <si...@martinelli.ch>.
Hi Claus,

Oh I misunderstood the fixedRate!

Thanks for your help,
Simon

-----Ursprüngliche Nachricht-----
Von: Claus Ibsen <cl...@gmail.com> 
Gesendet: Freitag, 5. August 2022 09:21
An: users@camel.apache.org
Betreff: 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
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Timer ensure that the route only runs once at a time

Posted by Simon Martinelli <si...@martinelli.ch>.
Thank you Alex

Holen Sie sich Outlook für Android<https://aka.ms/AAb9ysg>
________________________________
From: Mattern, Alex <al...@bbh.com.INVALID>
Sent: Monday, August 8, 2022 6:21:37 PM
To: users@camel.apache.org <us...@camel.apache.org>
Subject: RE: Timer ensure that the route only runs once at a time

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.mattern@bbh.com
www.bbh.com<http://www.bbh.com>

-----Original Message-----
From: Claus Ibsen <cl...@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.
******************************************************************************

RE: Timer ensure that the route only runs once at a time

Posted by "Mattern, Alex" <al...@bbh.com.INVALID>.
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.mattern@bbh.com
www.bbh.com

-----Original Message-----
From: Claus Ibsen <cl...@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.
******************************************************************************

Re: Timer ensure that the route only runs once at a time

Posted by Claus Ibsen <cl...@gmail.com>.
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
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2