Updated Branches:
  refs/heads/camel-2.11.x 21ea2d63f -> e3db2228a
  refs/heads/master 12fd86170 -> f099af733


CAMEL-6635: PollingConsumer from a scheduled consumer such as file/ftp can use 
a regular thread pool instead of being scheduled


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c7ebd0c1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c7ebd0c1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c7ebd0c1

Branch: refs/heads/master
Commit: c7ebd0c13b95c108e91584d2a3625a780bf3844c
Parents: 12fd861
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Aug 14 14:47:23 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Aug 14 14:47:23 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/impl/ScheduledPollConsumer.java   |  5 ++++-
 .../java/org/apache/camel/processor/PollEnricher.java  |  3 ++-
 .../camel/component/file/FilePollEnrichNoWaitTest.java | 13 +++----------
 3 files changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c7ebd0c1/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java 
b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
index 546b83a..ce015da 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
@@ -469,7 +469,10 @@ public abstract class ScheduledPollConsumer extends 
DefaultConsumer implements R
             LOG.trace("Before poll {}", getEndpoint());
         }
         scheduler.scheduleTask(this);
-        return timeout;
+
+        // ensure at least timeout is as long as one poll delay normally is
+        // to give the poll a chance to run once
+        return Math.max(timeout, getDelay());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/c7ebd0c1/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java 
b/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java
index 699362e..c79d3c9 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java
@@ -94,7 +94,8 @@ public class PollEnricher extends ServiceSupport implements 
AsyncProcessor {
     /**
      * Sets the timeout to use when polling.
      * <p/>
-     * Use 0 or negative to not use timeout and block until data is available.
+     * Use 0 to use receiveNoWait,
+     * Use -1 to use receive with no timeout (which will block until data is 
available).
      *
      * @param timeout timeout in millis.
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/c7ebd0c1/camel-core/src/test/java/org/apache/camel/component/file/FilePollEnrichNoWaitTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/component/file/FilePollEnrichNoWaitTest.java
 
b/camel-core/src/test/java/org/apache/camel/component/file/FilePollEnrichNoWaitTest.java
index 3f8baf4..61b0435 100644
--- 
a/camel-core/src/test/java/org/apache/camel/component/file/FilePollEnrichNoWaitTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/component/file/FilePollEnrichNoWaitTest.java
@@ -17,11 +17,9 @@
 package org.apache.camel.component.file;
 
 import java.io.File;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
@@ -58,19 +56,14 @@ public class FilePollEnrichNoWaitTest extends 
ContextTestSupport {
             public void configure() throws Exception {
                 from("timer:foo?period=1000").routeId("foo")
                     .log("Trigger timer foo")
-                    .pollEnrich("file:target/pollenrich?move=done")
+                    // use 0 as timeout for no wait
+                    .pollEnrich("file:target/pollenrich?move=done", 0)
                     .convertBodyTo(String.class)
                     .filter(body().isNull())
                         .stop()
                     .end()
                     .log("Polled filed ${file:name}")
-                    .to("mock:result")
-                    .process(new Processor() {
-                        public void process(Exchange exchange) throws 
Exception {
-                            // force stop route after use to prevent firing 
timer again
-                            exchange.getContext().stopRoute("foo", 100, 
TimeUnit.MILLISECONDS);
-                        }
-                    });
+                    .to("mock:result");
             }
         };
     }

Reply via email to