[ 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 9:12 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 but maybe it shouldn't since it puts all the entities as a List in one message. Here is a snippet that shows how I implemented receive(timeout). Added delay (consumer.delay works as well) as an option with 500 ms as default. It is used as well by the ScheduledPolled JPA consumer. Let me know if you'd prefer a new option altogether for JpaPollingConsumer. {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(delay); 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* (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} > 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