Hi Shiv,

The Camel component maintains a Map of the Timer objects that the endpoint
check when this method is called

public synchronized Timer getTimer() {
        if (timer == null) {
            TimerComponent tc = (TimerComponent)getComponent();
            timer = tc.getTimer(this); // CALL GET TIMER
        }
        return timer;
    }

--> WE CALL THE GETTIMER

    public Timer getTimer(TimerEndpoint endpoint) {
        String key = endpoint.getTimerName();
        if (!endpoint.isDaemon()) {
            key = "nonDaemon:" + key;
        }

        Timer answer;
        synchronized (timers) {
            answer = timers.get(key);
            if (answer == null) {
                // the timer name is also the thread name, so lets resolve
a name to be used
                String name =
endpoint.getCamelContext().getExecutorServiceManager().resolveThreadName("timer://"
+ endpoint.getTimerName()); // ENDPOINT NAME = THREADNAME
                answer = new Timer(name, endpoint.isDaemon());
                timers.put(key, answer);
            }
        }
        return answer;
    }

As you can see the name of the timer endpoint is used to do a lookup and
find the ThreadName associated and given it as parameter to the Timer class
of the JDK to create the timer job.

To answer to your question, if the name of the endpoint is the same, the
same Thread object and Thread will be used.

Regards,



On Tue, Sep 2, 2014 at 2:41 PM, Matt Sicker <boa...@gmail.com> wrote:

> I believe it's either speaking of Timer:
> http://docs.oracle.com/javase/7/docs/api/java/util/Timer.html
>
> Or it may be speaking of ScheduledExecutorService:
>
> http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html
>
>
> On 2 September 2014 02:52, Shiv <shiv.dixit....@gmail.com> wrote:
>
> > Hi,
> > I need to use a timer using format timer://kickoff?period=300000 which
> will
> > run every 5 minutes and pull records from DB and sends to JMS queue. As
> the
> > timer fires and busy processing if new timer will be fired again if the
> > timer interval expires? This timer endpoint is defined and used only once
> > in
> > the camel context.
> >
> > I tried to read through camel timer documentation but it is not clear
> there
> > yet it says "Where name is the name of the Timer object, which is created
> > and shared across endpoints. So if you use the same name for all your
> timer
> > endpoints, only one Timer object and thread will be used."
> >
> > Thanks
> > Shiv
> >
> >
> >
> >
> > --
> > View this message in context:
> > http://camel.465427.n5.nabble.com/Using-Timer-in-Camel-tp5755951.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> Matt Sicker <boa...@gmail.com>
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Reply via email to