On Sat, Mar 20, 2010 at 8:43 PM, tide08 <sachin2...@yahoo.com> wrote:
>
> So, would it make sense that in my customConsumer that extends
> ScheduledPollConsumer, I override doStart() to schedule more tasks? Is this
> thread-safe to do?
>

You can do that.
Also nothing is thread safe out of the box, its something that YOU
have to ensure.
And it depends what the scheduled task is doing etc.


>   �...@override
>    protected void doStart() throws Exception {
>
>        if (log.isDebugEnabled()) {
>            log.debug("Starting consumer: " + this);
>        }
>
>        ServiceHelper.startServices(getProcessor());
>
>        for(int i=0; i < threadPoolSize; i++){
>            if (isUseFixedDelay()) {
>                executorService.scheduleWithFixedDelay(this,
> getInitialDelay(), getDelay(), getTimeUnit());
>            } else {
>                executorService.scheduleAtFixedRate(this, getInitialDelay(),
> getDelay(), getTimeUnit());
>            }
>        }
>    }
>
>
>
>
> Claus Ibsen-2 wrote:
>>
>> On Fri, Mar 19, 2010 at 2:49 AM, tide08 <sachin2...@yahoo.com> wrote:
>>>
>>> Sorry, I am much confused at this point :(
>>>
>>> In regards to ScheduledPollConsumer,  is poll() method invoked by
>>> concurrent
>>> consumers? or is it just one consumer? I just see one thread invoking
>>> poll(), what is threadpool for than?
>>>
>>
>> Yes 1 thread. The thread pool can schedule as its a
>> ScheduledExecutorService.
>>
>>
>>> Thanks!
>>>
>>>
>>>
>>> tide08 wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am writing custom component and I need a polling consumer but I am not
>>>> sure, if the approach I am taking is correct. I need create
>>>> scheduledPollingConsumer which polls external system to receive
>>>> messages.
>>>>
>>>> Looking at other components SchedulePollingConsumers implement poll()
>>>> method which works with "known" number of messages i.e. Mail, File -
>>>> each
>>>> know what number of messages to work with inside of poll()
>>>>
>>>> //mail
>>>> int count = folder.getMessageCount();
>>>>
>>>> But in my scenario, there is no way to know it until you receive "null"
>>>> message from external system. So as I understand in my scenario, if
>>>> there
>>>> are tonnes of messages, this consumer will keep running indefinitely.
>>>> How
>>>> would this affect threadpool?
>>>>
>>>> How are ScheduledPollingConsumer supposed to behave? Consume as much in
>>>> polling interval? or consume restrictively so that the scheduled run
>>>> ends
>>>> before the next schedule?
>>>>
>>>> Please advice. Thanks!
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/ScheduledPollConsumer---poll%28%29-behavior--tp27942516p27950874.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/ScheduledPollConsumer---poll%28%29-behavior--tp27942516p27968018.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to