[ 
https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13054426#comment-13054426
 ] 

Babak Vahdat edited comment on CAMEL-4145 at 6/27/11 7:17 AM:
--------------------------------------------------------------

In the meanwhile I tried to dig into the code to understand how it works, 
correspondingly why it doesn't work in the case no timeout (or 0 timeout) is 
given to the pollEnrich DSL.

In general the problem is that if we've got a 0 timeout or even a very small 
timeout (let's say 50 milliseconds), the asynchronous thread gets simply no 
chance for polling to see if there's something there when we ask him.

Reflected this to the code: DefaultEndpoint.createPollingConsumer() returns a 
EventDrivenPollingConsumer object, which get's started while camel is booting 
up. The EventDrivenPollingConsumer.doStart() starts the consumer through 
ServiceHelper.startService(consumer), which would start up the asynchronuos 
polling through ScheduledPollConsumer.

Now if you for example put a Thread.sleep(2000) as the last statement inside 
EventDrivenPollingConsumer.doStart() method then the test case I submitted into 
the forum (see the link in the description above) would also work. The sleep 
delay on my box should be at least 2 second so that it works, as otherwise the 
ScheduledPollConsumer will have not enough chance to come into the play for 
polling.

Most probably putting that sleep(2000) call is not the (generic) way to go for. 
But it simply demonstrates where the problem is, that's somehow we've to give 
the asynchronous polling logic enough time to start polling the data, in my 
test case that was a file.

I hope all this makes sense to you, as my english is pretty poor. Sorry for 
that.

Babak

      was (Author: bvahdat):
    In the meanwhile I tried to dig into the code to understand how it works, 
correspondingly why it doesn't work in the case no timeout (or 0 timeout) is 
given to the pollEnrich DSL.

In general the problem is that if we've got a 0 timeout or even a very small 
timeout (let's say 50 milliseconds), the asynchronous thread gets simply no 
chance for polling to see if there's something there when we ask him.

Reflected this to the code: DefaultEndpoint.createPollingConsumer() returns a 
EventDrivenPollingConsumer object, which get's started while camel is booting 
up. The EventDrivenPollingConsumer.doStart() starts the consumer through 
ServiceHelper.startService(consumer), which would start up the asynchronuos 
polling through ScheduledPollConsumer.

Now if you for example put a Thread.currentThread().sleep(2000) as the last 
statement inside EventDrivenPollingConsumer.doStart() method then the test case 
I submitted into the forum (see the link in the description above) would also 
work. The sleep delay on my box should be at least 2 second so that it works, 
as otherwise the ScheduledPollConsumer will have not enough chance to come into 
the play for polling.

I'm pretty sure that putting that sleep(2000) call is not the way to go for. 
But it simply demonstrates where the problem is, that's somehow we've to give 
the asynchronous polling logic enough time to poll the data, in my test case 
that was a file.

I hope all this makes sense to you, as my english is pretty poor. Sorry for 
that.

Babak
  
> pollEnrich DSL behaves differently depending on a possibly explicitly given 
> timeout
> -----------------------------------------------------------------------------------
>
>                 Key: CAMEL-4145
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4145
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.2
>            Reporter: Babak Vahdat
>            Priority: Minor
>
> For details see the user forum:
> http://camel.465427.n5.nabble.com/Is-this-pollEnrich-s-expected-behaviour-td4517089.html

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to