You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Mathieu Lalonde (JIRA)" <ji...@apache.org> on 2011/09/05 18:01:11 UTC

[jira] [Issue Comment Edited] (CAMEL-3142) JpaPollingConsumer - So you can more easily work with pollEnrich

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

Mathieu Lalonde edited comment on CAMEL-3142 at 9/5/11 4:00 PM:
----------------------------------------------------------------

*Status Update* (with less confusion this time)

At the moment I have a JpaPollingConsumer that returns a list of polled entities. It supports all the PollingConsumer interface returning null when it couldn't poll anything. It supports maxMessagesPerPoll.
Here is a snippet that shows how I implemented receive(timeout).  Should I add "pollInterval" as a configurable option?

{code}
    public Exchange receive(long timeout) {
        final StopWatch stopWatch = new StopWatch();
        stopWatch.restart();
        
        List<?> polledEntities = doReceive();
        while (polledEntities == null && stopWatch.taken() < timeout) {
            try {
                Thread.sleep(pollInterval);
                polledEntities = doReceive();
            } catch (InterruptedException e) {
                log.trace("received(long timeout) interrupted after {} ms: Are we stopping: {}", stopWatch.taken(), isStopping());
            }
        }
        
        return createExchange(polledEntities);
    }
{code}





      was (Author: mrlalonde):
    *Status Update*

At the moment I have a JpaPollingConsumer that returns a list of polled entities. It supports receiveNoWait(..) & works with pollEnrich(uri) as long as there are items to be polled.  The other receive(..) methods do not block and I don't yet honor the timeout.  I simply return an empty list if there was nothing to poll.  I do support maxMessagesPerPoll.

Any thoughts or recommendation for receive() & receive(timeout)?
Any Camel idiom I should use for the timeout, I usually use a TimerTask.

  
> JpaPollingConsumer - So you can more easily work with pollEnrich
> ----------------------------------------------------------------
>
>                 Key: CAMEL-3142
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3142
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-jpa
>    Affects Versions: 2.4.0
>            Reporter: Claus Ibsen
>            Assignee: Mathieu Lalonde
>            Priority: Minor
>             Fix For: 2.9.0
>
>         Attachments: camel-jpa_initialPolish.patch
>
>
> See
> http://fusesource.com/forums/thread.jspa?threadID=2256&tstart=0
> The best solution is to add a JpaPollingConsumer implementation so it works better with pollEnrich

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