Re: any way to turn off a timer?

2013-10-28 Thread Willem jiang
I think the best way to turn off the timer is to stop the timer route.
As you just send the message to sera queue so the timer route is decoupled with 
the seda consumer route.


--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
  http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Sunday, October 27, 2013 at 3:22 AM, Keith Freeman wrote:

> I have a route with 2 sources, a timer and a seda queue. It uses the  
> timer to poll a data source while it's getting data from the queue, and  
> processes all of the data identically later in the route. But after a  
> while, the polled data source is exhausted while the seda queue (and the  
> route) will continue to run more-or-less forever.
>  
> So once I recognize that the polled data source is exhausted, I'd like  
> to turn off the timer so I don't have to start ignoring the polls from  
> it. I realize I might be able to use 2 separate routes and just stop  
> the timer route when it's done, but having only 1 route fits my design  
> much better.
>  
> So is there any way to turn off the timer? (BTW I don't know the number  
> of polls in advance, otherwise I know I could use the repeatCount parameter)





Re: any way to turn off a timer?

2013-10-28 Thread Keith Freeman
Thanks, but that won't work because it's a single route with 2 inputs: a 
timer and a seda queue.  So if I stop the route, I won't get the seda 
messages any more.


On 10/28/2013 01:21 AM, Willem jiang wrote:

I think the best way to turn off the timer is to stop the timer route.
As you just send the message to sera queue so the timer route is decoupled with 
the seda consumer route.


--
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
   http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem





On Sunday, October 27, 2013 at 3:22 AM, Keith Freeman wrote:


I have a route with 2 sources, a timer and a seda queue. It uses the
timer to poll a data source while it's getting data from the queue, and
processes all of the data identically later in the route. But after a
while, the polled data source is exhausted while the seda queue (and the
route) will continue to run more-or-less forever.
  
So once I recognize that the polled data source is exhausted, I'd like

to turn off the timer so I don't have to start ignoring the polls from
it. I realize I might be able to use 2 separate routes and just stop
the timer route when it's done, but having only 1 route fits my design
much better.
  
So is there any way to turn off the timer? (BTW I don't know the number

of polls in advance, otherwise I know I could use the repeatCount parameter)







Re: any way to turn off a timer?

2013-10-28 Thread Claus Ibsen
Its not as easy but you would have use the camel api from camel
context to get hold of the timer consumer and stop it manually.



On Mon, Oct 28, 2013 at 3:21 PM, Keith Freeman <8fo...@gmail.com> wrote:
> Thanks, but that won't work because it's a single route with 2 inputs: a
> timer and a seda queue.  So if I stop the route, I won't get the seda
> messages any more.
>
>
> On 10/28/2013 01:21 AM, Willem jiang wrote:
>>
>> I think the best way to turn off the timer is to stop the timer route.
>> As you just send the message to sera queue so the timer route is decoupled
>> with the seda consumer route.
>>
>>
>> --
>> Willem Jiang
>>
>> Red Hat, Inc.
>> Web: http://www.redhat.com
>> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
>> (English)
>>http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
>> Twitter: willemjiang
>> Weibo: 姜宁willem
>>
>>
>>
>>
>>
>> On Sunday, October 27, 2013 at 3:22 AM, Keith Freeman wrote:
>>
>>> I have a route with 2 sources, a timer and a seda queue. It uses the
>>> timer to poll a data source while it's getting data from the queue, and
>>> processes all of the data identically later in the route. But after a
>>> while, the polled data source is exhausted while the seda queue (and the
>>> route) will continue to run more-or-less forever.
>>>   So once I recognize that the polled data source is exhausted, I'd like
>>> to turn off the timer so I don't have to start ignoring the polls from
>>> it. I realize I might be able to use 2 separate routes and just stop
>>> the timer route when it's done, but having only 1 route fits my design
>>> much better.
>>>   So is there any way to turn off the timer? (BTW I don't know the number
>>> of polls in advance, otherwise I know I could use the repeatCount
>>> parameter)
>>
>>
>>
>



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: any way to turn off a timer?

2013-11-04 Thread Keith Freeman

For anybody who finds this thread, here's how I got it working:

1) get a reference to the TimerEndpoint for the timer -- you can get 
this from the first Exchange (e.g. 
ex.getFromEndpoint().getEndpointUri().startsWith("timer")), or from the 
RouteDefinition (rd.getInputs(), find the FromDefinition where 
getUri().startsWith("timer")), or maybe from the CamelContext
2) when you've finished handling timer polls, call 
TimerEndpoint.getTimer().cancel()


Note you could also purge() or even reschedule the timer from the 
getTimer() interface (which is a standard Java Timer).


On 10/28/2013 08:45 AM, Claus Ibsen wrote:

Its not as easy but you would have use the camel api from camel
context to get hold of the timer consumer and stop it manually.



On Mon, Oct 28, 2013 at 3:21 PM, Keith Freeman <8fo...@gmail.com> wrote:

Thanks, but that won't work because it's a single route with 2 inputs: a
timer and a seda queue.  So if I stop the route, I won't get the seda
messages any more.


On 10/28/2013 01:21 AM, Willem jiang wrote:

I think the best way to turn off the timer is to stop the timer route.
As you just send the message to sera queue so the timer route is decoupled
with the seda consumer route.


--
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
(English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem





On Sunday, October 27, 2013 at 3:22 AM, Keith Freeman wrote:


I have a route with 2 sources, a timer and a seda queue. It uses the
timer to poll a data source while it's getting data from the queue, and
processes all of the data identically later in the route. But after a
while, the polled data source is exhausted while the seda queue (and the
route) will continue to run more-or-less forever.
   So once I recognize that the polled data source is exhausted, I'd like
to turn off the timer so I don't have to start ignoring the polls from
it. I realize I might be able to use 2 separate routes and just stop
the timer route when it's done, but having only 1 route fits my design
much better.
   So is there any way to turn off the timer? (BTW I don't know the number
of polls in advance, otherwise I know I could use the repeatCount
parameter)