You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Babak Vahdat (JIRA)" <ji...@apache.org> on 2011/06/23 18:13:47 UTC

[jira] [Created] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

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

        

[jira] [Assigned] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-4145:
----------------------------------

    Assignee: Claus Ibsen

> 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
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.0, 2.9.0
>
>
> 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

        

[jira] [Issue Comment Edited] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Babak Vahdat (JIRA)" <ji...@apache.org>.
    [ 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

        

[jira] [Updated] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Babak Vahdat (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Babak Vahdat updated CAMEL-4145:
--------------------------------

    Comment: was deleted

(was: What I meant in my previous comment was a Thread.sleep(2000) call which is actually a shorthand-writing for Thread.currentThread().sleep(2000).)

> 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

        

[jira] [Commented] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Babak Vahdat (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13054511#comment-13054511 ] 

Babak Vahdat commented on CAMEL-4145:
-------------------------------------

For the sake of clarity, following the change I made on EventDrivenPollingConsumer to make my submitted test case pass:

{code}
	protected void doStart() throws Exception {
		// lets add ourselves as a consumer
		consumer = getEndpoint().createConsumer(this);
		ServiceHelper.startService(consumer);

		// in the case our consumer is a (asynchronous) polling one, wait a bit
		// on this thread until the consumer comes up and starts consuming
		// properly before go further on this thread
		if (PollingConsumer.class.isInstance(consumer)) {
			Thread.sleep(2000);
		}
	}
{code}

> 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

        

[jira] [Issue Comment Edited] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Babak Vahdat (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13054511#comment-13054511 ] 

Babak Vahdat edited comment on CAMEL-4145 at 6/24/11 3:49 PM:
--------------------------------------------------------------

For the sake of clarity, following the change I made on EventDrivenPollingConsumer to make my submitted test case pass:

{code}
	protected void doStart() throws Exception {
		// lets add ourselves as a consumer
		consumer = getEndpoint().createConsumer(this);
		ServiceHelper.startService(consumer);

		// in the case our consumer is a scheduled polling one, wait a bit
		// on this thread until the consumer comes up and starts consuming
		// properly before go further on this thread
		if (ScheduledPollConsumer.class.isInstance(consumer)) {
			Thread.sleep(2000);
		}
	}

{code}

      was (Author: bvahdat):
    For the sake of clarity, following the change I made on EventDrivenPollingConsumer to make my submitted test case pass:

{code}
	protected void doStart() throws Exception {
		// lets add ourselves as a consumer
		consumer = getEndpoint().createConsumer(this);
		ServiceHelper.startService(consumer);

		// in the case our consumer is a (asynchronous) polling one, wait a bit
		// on this thread until the consumer comes up and starts consuming
		// properly before go further on this thread
		if (PollingConsumer.class.isInstance(consumer)) {
			Thread.sleep(2000);
		}
	}
{code}
  
> 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

        

[jira] [Commented] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Babak Vahdat (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13054426#comment-13054426 ] 

Babak Vahdat commented on CAMEL-4145:
-------------------------------------

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

        

[jira] [Updated] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-4145:
-------------------------------

    Fix Version/s: 2.9.0
                   2.8.0

> 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
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.0, 2.9.0
>
>
> 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

        

[jira] [Commented] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13056497#comment-13056497 ] 

Claus Ibsen commented on CAMEL-4145:
------------------------------------

The consumer acts correctly when you use no timeout as it will do a NoWait, which mean it checks if there was a message immediately available. For a file/ftp thats not the case as it would have to go pool for that. You can't expect a NoWait to connect to a remote FTP server, traverse a directory structure, download the desired file, etc. All that takes time. NoWait is a immediately check for any existing messages.

If you on the other hand use seda, then you can use a NoWait polling as the seda queue may have messages ready at hand already.

However I think the default aggregator should set an empty message in case the was no message to poll.
Likewise we should set the TO_ENDPOINT header, that is used to keep track of endpoints that the message is being send to.


> 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
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.0, 2.9.0
>
>
> 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

        

[jira] [Resolved] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-4145.
--------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 2.9.0)

Now an empty message body will be set if pollEnrich cannot poll the resource.

> 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
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.0
>
>
> 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

        

[jira] [Commented] (CAMEL-4145) pollEnrich DSL behaves differently depending on a possibly explicitly given timeout

Posted by "Babak Vahdat (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13054430#comment-13054430 ] 

Babak Vahdat commented on CAMEL-4145:
-------------------------------------

What I meant in my previous comment was a Thread.sleep(2000) call which is actually a shorthand-writing for Thread.currentThread().sleep(2000).

> 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