camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/8] camel git commit: CAMEL-7999: Scheduled poll endpoints should include all its consumer related options as well in component documentation.
Date Fri, 13 Feb 2015 11:48:11 GMT
Repository: camel
Updated Branches:
  refs/heads/master 64efcea1f -> 85ab834f2


CAMEL-7999: Scheduled poll endpoints should include all its consumer related options as well
in component documentation.


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

Branch: refs/heads/master
Commit: 82eaad58a1d97417f9d7af166d2a01e8685ae15c
Parents: 6290057
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Feb 13 08:50:12 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Feb 13 12:48:32 2015 +0100

----------------------------------------------------------------------
 .../camel/impl/ScheduledPollConsumer.java       |  58 +--
 .../camel/impl/ScheduledPollEndpoint.java       | 418 +++++++++++++++----
 .../FileConsumerPollStrategyNotBeginTest.java   |   2 +-
 ...eConsumerPollStrategyPolledMessagesTest.java |   2 +-
 ...rPollStrategyRollbackThrowExceptionTest.java |   2 +-
 ...eConsumerPollStrategyStopOnRollbackTest.java |   2 +-
 .../file/FileConsumerPollStrategyTest.java      |   2 +-
 7 files changed, 333 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/82eaad58/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 e300d49..a786214 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
@@ -30,7 +30,6 @@ import org.apache.camel.Processor;
 import org.apache.camel.SuspendableService;
 import org.apache.camel.spi.PollingConsumerPollStrategy;
 import org.apache.camel.spi.ScheduledPollConsumerScheduler;
-import org.apache.camel.spi.UriParam;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
@@ -46,30 +45,18 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements
R
     private ScheduledPollConsumerScheduler scheduler;
     private ScheduledExecutorService scheduledExecutorService;
 
-    // if adding more options then align with ScheduledPollEndpoint#configureScheduledPollConsumerProperties
-    @UriParam
+    // if adding more options then align with org.apache.camel.impl.ScheduledPollEndpoint
     private boolean startScheduler = true;
-    @UriParam
     private long initialDelay = 1000;
-    @UriParam
     private long delay = 500;
-    @UriParam
     private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
-    @UriParam
     private boolean useFixedDelay = true;
-    @UriParam
     private PollingConsumerPollStrategy pollStrategy = new DefaultPollingConsumerPollStrategy();
-    @UriParam
     private LoggingLevel runLoggingLevel = LoggingLevel.TRACE;
-    @UriParam
     private boolean sendEmptyMessageWhenIdle;
-    @UriParam
     private boolean greedy;
-    @UriParam
     private int backoffMultiplier;
-    @UriParam
     private int backoffIdleThreshold;
-    @UriParam
     private int backoffErrorThreshold;
     private Map<String, Object> schedulerProperties;
 
@@ -280,11 +267,6 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements
R
         return scheduler;
     }
 
-    /**
-     * Sets a custom scheduler to use for scheduling running this task (poll).
-     *
-     * @param scheduler the custom scheduler
-     */
     public void setScheduler(ScheduledPollConsumerScheduler scheduler) {
         this.scheduler = scheduler;
     }
@@ -293,9 +275,6 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements
R
         return schedulerProperties;
     }
 
-    /**
-     * Additional properties to configure on the custom scheduler.
-     */
     public void setSchedulerProperties(Map<String, Object> schedulerProperties) {
         this.schedulerProperties = schedulerProperties;
     }
@@ -320,15 +299,6 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements
R
         return timeUnit;
     }
 
-    /**
-     * Sets the time unit to use.
-     * <p/>
-     * Notice that both {@link #getDelay()} and {@link #getInitialDelay()} are using
-     * the same time unit. So if you change this value, then take into account that the
-     * default value of {@link #getInitialDelay()} is 1000. So you may to adjust this value
accordingly.
-     *
-     * @param timeUnit the time unit.
-     */
     public void setTimeUnit(TimeUnit timeUnit) {
         this.timeUnit = timeUnit;
     }
@@ -361,13 +331,6 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements
R
         return startScheduler;
     }
 
-    /**
-     * Sets whether the scheduler should be started when this consumer starts.
-     * <p/>
-     * This option is default true.
-     *
-     * @param startScheduler whether to start scheduler
-     */
     public void setStartScheduler(boolean startScheduler) {
         this.startScheduler = startScheduler;
     }
@@ -384,9 +347,6 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements
R
         return greedy;
     }
 
-    /**
-     * If greedy then a poll is executed immediate after a previous poll that polled 1 or
more messages.
-     */
     public void setGreedy(boolean greedy) {
         this.greedy = greedy;
     }
@@ -423,26 +383,10 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer
implements R
         return scheduledExecutorService;
     }
 
-    /**
-     * Whether the scheduler has been started.
-     * <p/>
-     * The scheduler can be started with the {@link #startScheduler()} method.
-     *
-     * @return <tt>true</tt> if started, <tt>false</tt> if not.
-     */
     public boolean isSchedulerStarted() {
         return scheduler.isSchedulerStarted();
     }
 
-    /**
-     * Sets a custom shared {@link ScheduledExecutorService} to use as thread pool
-     * <p/>
-     * <b>Notice: </b> When using a custom thread pool, then the lifecycle of
this thread
-     * pool is not controlled by this consumer (eg this consumer will not start/stop the
thread pool
-     * when the consumer is started/stopped etc.)
-     *
-     * @param scheduledExecutorService the custom thread pool to use
-     */
     public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
{
         this.scheduledExecutorService = scheduledExecutorService;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/82eaad58/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
index 57595b1..182a683 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
@@ -18,11 +18,18 @@ package org.apache.camel.impl;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
+import org.apache.camel.LoggingLevel;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.spi.PollingConsumerPollStrategy;
+import org.apache.camel.spi.ScheduledPollConsumerScheduler;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.IntrospectionSupport;
 
@@ -36,6 +43,41 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint {
     private static final String SPRING_SCHEDULER = "org.apache.camel.spring.pollingconsumer.SpringScheduledPollConsumerScheduler";
     private static final String QUARTZ_2_SCHEDULER = "org.apache.camel.pollconsumer.quartz2.QuartzScheduledPollConsumerScheduler";
 
+    private boolean consumerPropertiesInUse;
+    private String schedulerName;
+
+    // if adding more options then align with org.apache.camel.impl.ScheduledPollConsumer
+    @UriParam(defaultValue = "true", label = "consumer")
+    private boolean startScheduler = true;
+    @UriParam(defaultValue = "1000", label = "consumer")
+    private long initialDelay = 1000;
+    @UriParam(defaultValue = "500", label = "consumer")
+    private long delay = 500;
+    @UriParam(defaultValue = "MILLISECONDS", label = "consumer")
+    private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
+    @UriParam(defaultValue = "true", label = "consumer")
+    private boolean useFixedDelay = true;
+    @UriParam(label = "consumer")
+    private PollingConsumerPollStrategy pollStrategy = new DefaultPollingConsumerPollStrategy();
+    @UriParam(defaultValue = "TRACE", label = "consumer")
+    private LoggingLevel runLoggingLevel = LoggingLevel.TRACE;
+    @UriParam(label = "consumer")
+    private boolean sendEmptyMessageWhenIdle;
+    @UriParam(label = "consumer")
+    private boolean greedy;
+    @UriParam(enums = "spring,quartz2", label = "consumer")
+    private ScheduledPollConsumerScheduler scheduler;
+    @UriParam(label = "consumer")
+    private Map<String, Object> schedulerProperties;
+    @UriParam(label = "consumer")
+    private ScheduledExecutorService scheduledExecutorService;
+    @UriParam(label = "consumer")
+    private int backoffMultiplier;
+    @UriParam(label = "consumer")
+    private int backoffIdleThreshold;
+    @UriParam(label = "consumer")
+    private int backoffErrorThreshold;
+
     protected ScheduledPollEndpoint(String endpointUri, Component component) {
         super(endpointUri, component);
     }
@@ -62,98 +104,28 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint {
         // special for scheduled poll consumers as we want to allow end users to configure
its options
         // from the URI parameters without the consumer. prefix
         Map<String, Object> schedulerProperties = IntrospectionSupport.extractProperties(options,
"scheduler.");
-        Object startScheduler = options.remove("startScheduler");
-        Object initialDelay = options.remove("initialDelay");
-        Object delay = options.remove("delay");
-        Object timeUnit = options.remove("timeUnit");
-        Object useFixedDelay = options.remove("useFixedDelay");
-        Object pollStrategy = options.remove("pollStrategy");
-        Object runLoggingLevel = options.remove("runLoggingLevel");
-        Object sendEmptyMessageWhenIdle = options.remove("sendEmptyMessageWhenIdle");
-        Object greedy = options.remove("greedy");
-        Object scheduledExecutorService  = options.remove("scheduledExecutorService");
-        Object scheduler  = options.remove("scheduler");
-        Object backoffMultiplier  = options.remove("backoffMultiplier");
-        Object backoffIdleThreshold  = options.remove("backoffIdleThreshold");
-        Object backoffErrorThreshold  = options.remove("backoffErrorThreshold");
-        boolean setConsumerProperties = false;
-
-        // the following is split into two if statements to satisfy the checkstyle max complexity
constraint
-        if (initialDelay != null || delay != null || timeUnit != null || useFixedDelay !=
null || pollStrategy != null) {
-            setConsumerProperties = true;
-        }
-        if (runLoggingLevel != null || startScheduler != null || sendEmptyMessageWhenIdle
!= null || greedy != null || scheduledExecutorService != null) {
-            setConsumerProperties = true;
-        }
-        if (scheduler != null || !schedulerProperties.isEmpty() || backoffMultiplier != null
|| backoffIdleThreshold != null || backoffErrorThreshold != null) {
-            setConsumerProperties = true;
-        }
-
-        if (setConsumerProperties) {
-
-            if (consumerProperties == null) {
-                consumerProperties = new HashMap<String, Object>();
-            }
-            if (initialDelay != null) {
-                consumerProperties.put("initialDelay", initialDelay);
-            }
-            if (startScheduler != null) {
-                consumerProperties.put("startScheduler", startScheduler);
-            }
-            if (delay != null) {
-                consumerProperties.put("delay", delay);
-            }
-            if (timeUnit != null) {
-                consumerProperties.put("timeUnit", timeUnit);
-            }
-            if (useFixedDelay != null) {
-                consumerProperties.put("useFixedDelay", useFixedDelay);
-            }
-            if (pollStrategy != null) {
-                consumerProperties.put("pollStrategy", pollStrategy);
-            }
-            if (runLoggingLevel != null) {
-                consumerProperties.put("runLoggingLevel", runLoggingLevel);
-            }
-            if (sendEmptyMessageWhenIdle != null) {
-                consumerProperties.put("sendEmptyMessageWhenIdle", sendEmptyMessageWhenIdle);
-            }
-            if (greedy != null) {
-                consumerProperties.put("greedy", greedy);
-            }
-            if (scheduledExecutorService != null) {
-                consumerProperties.put("scheduledExecutorService", scheduledExecutorService);
-            }
-            if (scheduler != null) {
-                // special for scheduler if its "spring"
-                if ("spring".equals(scheduler)) {
-                    try {
-                        Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(SPRING_SCHEDULER);
-                        scheduler = getCamelContext().getInjector().newInstance(clazz);
-                    } catch (ClassNotFoundException e) {
-                        throw new IllegalArgumentException("Cannot load " + SPRING_SCHEDULER
+ " from classpath. Make sure camel-spring.jar is on the classpath.", e);
-                    }
-                } else if ("quartz2".equals(scheduler)) {
-                    try {
-                        Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(QUARTZ_2_SCHEDULER);
-                        scheduler = getCamelContext().getInjector().newInstance(clazz);
-                    } catch (ClassNotFoundException e) {
-                        throw new IllegalArgumentException("Cannot load " + QUARTZ_2_SCHEDULER
+ " from classpath. Make sure camel-quarz2.jar is on the classpath.", e);
-                    }
+        if (schedulerProperties != null && !schedulerProperties.isEmpty()) {
+            setSchedulerProperties(schedulerProperties);
+        }
+
+        if (scheduler == null && schedulerName != null) {
+            // special for scheduler if its "spring"
+            if ("spring".equals(schedulerName)) {
+                try {
+                    Class<? extends ScheduledPollConsumerScheduler> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(SPRING_SCHEDULER,
ScheduledPollConsumerScheduler.class);
+                    setScheduler(getCamelContext().getInjector().newInstance(clazz));
+                } catch (ClassNotFoundException e) {
+                    throw new IllegalArgumentException("Cannot load " + SPRING_SCHEDULER
+ " from classpath. Make sure camel-spring.jar is on the classpath.", e);
                 }
-                consumerProperties.put("scheduler", scheduler);
-            }
-            if (!schedulerProperties.isEmpty()) {
-                consumerProperties.put("schedulerProperties", schedulerProperties);
-            }
-            if (backoffMultiplier != null) {
-                consumerProperties.put("backoffMultiplier", backoffMultiplier);
-            }
-            if (backoffIdleThreshold != null) {
-                consumerProperties.put("backoffIdleThreshold", backoffIdleThreshold);
-            }
-            if (backoffErrorThreshold != null) {
-                consumerProperties.put("backoffErrorThreshold", backoffErrorThreshold);
+            } else if ("quartz2".equals(schedulerName)) {
+                try {
+                    Class<? extends ScheduledPollConsumerScheduler> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(QUARTZ_2_SCHEDULER,
ScheduledPollConsumerScheduler.class);
+                    setScheduler(getCamelContext().getInjector().newInstance(clazz));
+                } catch (ClassNotFoundException e) {
+                    throw new IllegalArgumentException("Cannot load " + QUARTZ_2_SCHEDULER
+ " from classpath. Make sure camel-quarz2.jar is on the classpath.", e);
+                }
+            } else {
+                setScheduler(CamelContextHelper.mandatoryLookup(getCamelContext(), schedulerName,
ScheduledPollConsumerScheduler.class));
             }
         }
     }
@@ -179,4 +151,268 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint
{
         }
     }
 
+    @Override
+    protected void doStart() throws Exception {
+        // if any of the consumer properties was configured then we need to initialize the
options before starting
+        if (consumerPropertiesInUse) {
+            initConsumerProperties();
+        }
+
+        super.doStart();
+    }
+
+    protected void initConsumerProperties() {
+        // must setup consumer properties before we are ready to start
+        Map<String, Object> options = getConsumerProperties();
+        if (!options.containsKey("startScheduler")) {
+            options.put("startScheduler", isStartScheduler());
+        }
+        if (!options.containsKey("initialDelay")) {
+            options.put("initialDelay", getInitialDelay());
+        }
+        if (!options.containsKey("delay")) {
+            options.put("delay", getDelay());
+        }
+        if (!options.containsKey("timeUnit")) {
+            options.put("timeUnit", getTimeUnit());
+        }
+        if (!options.containsKey("useFixedDelay")) {
+            options.put("useFixedDelay", isUseFixedDelay());
+        }
+        if (!options.containsKey("pollStrategy")) {
+            options.put("pollStrategy", getPollStrategy());
+        }
+        if (!options.containsKey("runLoggingLevel")) {
+            options.put("runLoggingLevel", getRunLoggingLevel());
+        }
+        if (!options.containsKey("sendEmptyMessageWhenIdle")) {
+            options.put("sendEmptyMessageWhenIdle", isSendEmptyMessageWhenIdle());
+        }
+        if (!options.containsKey("greedy")) {
+            options.put("greedy", isGreedy());
+        }
+        if (!options.containsKey("scheduler")) {
+            options.put("scheduler", getScheduler());
+        }
+        if (!options.containsKey("schedulerProperties")) {
+            options.put("schedulerProperties", getSchedulerProperties());
+        }
+        if (!options.containsKey("scheduledExecutorService")) {
+            options.put("scheduledExecutorService", getScheduledExecutorService());
+        }
+        if (!options.containsKey("backoffMultiplier")) {
+            options.put("backoffMultiplier", getBackoffMultiplier());
+        }
+        if (!options.containsKey("backoffIdleThreshold")) {
+            options.put("backoffIdleThreshold", getBackoffIdleThreshold());
+        }
+        if (!options.containsKey("backoffErrorThreshold")) {
+            options.put("backoffErrorThreshold", getBackoffErrorThreshold());
+        }
+    }
+
+    public boolean isStartScheduler() {
+        return startScheduler;
+    }
+
+    /**
+     * Whether the scheduler should be auto started.
+     */
+    public void setStartScheduler(boolean startScheduler) {
+        this.startScheduler = startScheduler;
+        consumerPropertiesInUse = true;
+    }
+
+    public long getInitialDelay() {
+        return initialDelay;
+    }
+
+    /**
+     * Milliseconds before the first poll starts.
+     */
+    public void setInitialDelay(long initialDelay) {
+        this.initialDelay = initialDelay;
+        consumerPropertiesInUse = true;
+    }
+
+    public long getDelay() {
+        return delay;
+    }
+
+    /**
+     * Milliseconds before the next poll.
+     */
+    public void setDelay(long delay) {
+        this.delay = delay;
+        consumerPropertiesInUse = true;
+    }
+
+    public TimeUnit getTimeUnit() {
+        return timeUnit;
+    }
+
+    /**
+     * Time unit for initialDelay and delay options.
+     */
+    public void setTimeUnit(TimeUnit timeUnit) {
+        this.timeUnit = timeUnit;
+        consumerPropertiesInUse = true;
+    }
+
+    public boolean isUseFixedDelay() {
+        return useFixedDelay;
+    }
+
+    /**
+     * Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK
for details.
+     */
+    public void setUseFixedDelay(boolean useFixedDelay) {
+        this.useFixedDelay = useFixedDelay;
+        consumerPropertiesInUse = true;
+    }
+
+    public PollingConsumerPollStrategy getPollStrategy() {
+        return pollStrategy;
+    }
+
+    /**
+     * A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide
your custom implementation
+     * to control error handling usually occurred during the poll operation before an Exchange
have been created
+     * and being routed in Camel. In other words the error occurred while the polling was
gathering information,
+     * for instance access to a file network failed so Camel cannot access it to scan for
files.
+     * The default implementation will log the caused exception at WARN level and ignore
it.
+     */
+    public void setPollStrategy(PollingConsumerPollStrategy pollStrategy) {
+        this.pollStrategy = pollStrategy;
+        consumerPropertiesInUse = true;
+    }
+
+    public LoggingLevel getRunLoggingLevel() {
+        return runLoggingLevel;
+    }
+
+    /**
+     * The consumer logs a start/complete log line when it polls. This option allows you
to configure the logging level for that.
+     */
+    public void setRunLoggingLevel(LoggingLevel runLoggingLevel) {
+        this.runLoggingLevel = runLoggingLevel;
+        consumerPropertiesInUse = true;
+    }
+
+    public boolean isSendEmptyMessageWhenIdle() {
+        return sendEmptyMessageWhenIdle;
+    }
+
+    /**
+     * If the polling consumer did not poll any files, you can enable this option to send
an empty message (no body) instead.
+     */
+    public void setSendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle) {
+        this.sendEmptyMessageWhenIdle = sendEmptyMessageWhenIdle;
+        consumerPropertiesInUse = true;
+    }
+
+    public boolean isGreedy() {
+        return greedy;
+    }
+
+    /**
+     * If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if
the previous run polled 1 or more messages.
+     */
+    public void setGreedy(boolean greedy) {
+        this.greedy = greedy;
+        consumerPropertiesInUse = true;
+    }
+
+    public ScheduledPollConsumerScheduler getScheduler() {
+        return scheduler;
+    }
+
+    /**
+     * Allow to plugin a custom org.apache.camel.spi.ScheduledPollConsumerScheduler to use
as the scheduler for
+     * firing when the polling consumer runs. The default implementation uses the ScheduledExecutorService
and
+     * there is a Quartz2, and Spring based which supports CRON expressions.
+     *
+     * Notice: If using a custom scheduler then the options for initialDelay, useFixedDelay,
timeUnit,
+     * and scheduledExecutorService may not be in use. Use the text quartz2 to refer to use
the Quartz2 scheduler;
+     * and use the text spring to use the Spring based; and use the text #myScheduler to
refer to a custom scheduler
+     * by its id in the Registry. See Quartz2 page for an example.
+     */
+    public void setScheduler(ScheduledPollConsumerScheduler scheduler) {
+        this.scheduler = scheduler;
+        consumerPropertiesInUse = true;
+    }
+
+    /**
+     * Allow to plugin a custom org.apache.camel.spi.ScheduledPollConsumerScheduler to use
as the scheduler for
+     * firing when the polling consumer runs. This option is used for referring to one of
the built-in schedulers
+     * either <tt>spring</tt>, or <tt>quartz2</tt>.
+     */
+    public void setScheduler(String schedulerName) {
+        this.schedulerName = schedulerName;
+        consumerPropertiesInUse = true;
+    }
+
+    public Map<String, Object> getSchedulerProperties() {
+        return schedulerProperties;
+    }
+
+    /**
+     * To configure additional properties when using a custom scheduler or any of the Quartz2,
Spring based scheduler.
+     */
+    public void setSchedulerProperties(Map<String, Object> schedulerProperties) {
+        this.schedulerProperties = schedulerProperties;
+        consumerPropertiesInUse = true;
+    }
+
+    public ScheduledExecutorService getScheduledExecutorService() {
+        return scheduledExecutorService;
+    }
+
+    /**
+     * Allows for configuring a custom/shared thread pool to use for the consumer.
+     * By default each consumer has its own single threaded thread pool.
+     * This option allows you to share a thread pool among multiple consumers.
+     */
+    public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
{
+        this.scheduledExecutorService = scheduledExecutorService;
+        consumerPropertiesInUse = true;
+    }
+
+    public int getBackoffMultiplier() {
+        return backoffMultiplier;
+    }
+
+    /**
+     * To let the scheduled polling consumer backoff if there has been a number of subsequent
idles/errors in a row.
+     * The multiplier is then the number of polls that will be skipped before the next actual
attempt is happening again.
+     * When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold
must also be configured.
+     */
+    public void setBackoffMultiplier(int backoffMultiplier) {
+        this.backoffMultiplier = backoffMultiplier;
+        consumerPropertiesInUse = true;
+    }
+
+    public int getBackoffIdleThreshold() {
+        return backoffIdleThreshold;
+    }
+
+    /**
+     * The number of subsequent idle polls that should happen before the backoffMultipler
should kick-in.
+     */
+    public void setBackoffIdleThreshold(int backoffIdleThreshold) {
+        this.backoffIdleThreshold = backoffIdleThreshold;
+        consumerPropertiesInUse = true;
+    }
+
+    public int getBackoffErrorThreshold() {
+        return backoffErrorThreshold;
+    }
+
+    /**
+     * The number of subsequent error polls (failed due some error) that should happen before
the backoffMultipler should kick-in.
+     */
+    public void setBackoffErrorThreshold(int backoffErrorThreshold) {
+        this.backoffErrorThreshold = backoffErrorThreshold;
+        consumerPropertiesInUse = true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/82eaad58/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyNotBeginTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyNotBeginTest.java
b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyNotBeginTest.java
index 6fb087a..a019d2c 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyNotBeginTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyNotBeginTest.java
@@ -44,8 +44,8 @@ public class FileConsumerPollStrategyNotBeginTest extends ContextTestSupport
{
 
     @Override
     protected void setUp() throws Exception {
-        super.setUp();
         deleteDirectory("target/pollstrategy");
+        super.setUp();
         template.sendBodyAndHeader("file:target/pollstrategy/", "Hello World", Exchange.FILE_NAME,
"hello.txt");
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/82eaad58/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyPolledMessagesTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyPolledMessagesTest.java
b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyPolledMessagesTest.java
index 2714fc2..f88198c 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyPolledMessagesTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyPolledMessagesTest.java
@@ -47,8 +47,8 @@ public class FileConsumerPollStrategyPolledMessagesTest extends ContextTestSuppo
 
     @Override
     protected void setUp() throws Exception {
-        super.setUp();
         deleteDirectory("target/pollstrategy");
+        super.setUp();
     }
 
     public void testPolledMessages() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/82eaad58/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
index 0894f33..25ffa9c 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
@@ -42,8 +42,8 @@ public class FileConsumerPollStrategyRollbackThrowExceptionTest extends
ContextT
 
     @Override
     protected void setUp() throws Exception {
-        super.setUp();
         deleteDirectory("target/pollstrategy");
+        super.setUp();
         template.sendBodyAndHeader("file:target/pollstrategy/", "Hello World", Exchange.FILE_NAME,
"hello.txt");
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/82eaad58/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyStopOnRollbackTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyStopOnRollbackTest.java
b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyStopOnRollbackTest.java
index 68d788f..0408ae3 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyStopOnRollbackTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyStopOnRollbackTest.java
@@ -45,8 +45,8 @@ public class FileConsumerPollStrategyStopOnRollbackTest extends ContextTestSuppo
 
     @Override
     protected void setUp() throws Exception {
-        super.setUp();
         deleteDirectory("target/pollstrategy");
+        super.setUp();
         template.sendBodyAndHeader("file:target/pollstrategy/", "Hello World", Exchange.FILE_NAME,
"hello.txt");
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/82eaad58/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyTest.java
b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyTest.java
index 714965b..2769bae 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyTest.java
@@ -44,8 +44,8 @@ public class FileConsumerPollStrategyTest extends ContextTestSupport {
 
     @Override
     protected void setUp() throws Exception {
-        super.setUp();
         deleteDirectory("target/pollstrategy");
+        super.setUp();
         template.sendBodyAndHeader("file:target/pollstrategy/", "Hello World", Exchange.FILE_NAME,
"hello.txt");
     }
 


Mime
View raw message