camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1067615 - in /camel/trunk/components/camel-quartz/src: main/java/org/apache/camel/component/quartz/QuartzComponent.java test/java/org/apache/camel/component/quartz/QuartzNameCollisionTest.java
Date Sun, 06 Feb 2011 08:49:18 GMT
Author: davsclaus
Date: Sun Feb  6 08:49:18 2011
New Revision: 1067615

URL: http://svn.apache.org/viewvc?rev=1067615&view=rev
Log:
CAMEL-3239: Fixed unique jobname check for stateful jobs. Thanks to Tracy Snell for the patch.

Modified:
    camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
    camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzNameCollisionTest.java

Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java?rev=1067615&r1=1067614&r2=1067615&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
(original)
+++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
Sun Feb  6 08:49:18 2011
@@ -112,9 +112,10 @@ public class QuartzComponent extends Def
         Map<String, Object> jobParameters = IntrospectionSupport.extractProperties(parameters,
"job.");
 
         Trigger trigger;
+        boolean stateful = "true".equals(parameters.get("stateful"));
 
-        // if we're starting up and not running in Quartz clustered mode then check for a
name conflict.
-        if (!isClustered()) {
+        // if we're starting up and not running in Quartz clustered mode or not stateful
then check for a name conflict.
+        if (!isClustered() && !stateful) {
             // check to see if this trigger already exists
             trigger = getScheduler().getTrigger(name, group);
             if (trigger != null) {
@@ -267,7 +268,7 @@ public class QuartzComponent extends Def
                 LOG.debug("Cannot delete job using trigger: " + group + "/" + name + " as
the JobStore is clustered.");
             }
         } else {
-            Trigger trigger  = getScheduler().getTrigger(name, group);
+            Trigger trigger = getScheduler().getTrigger(name, group);
             if (trigger != null) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Deleting job using trigger: " + group + "/" + name);

Modified: camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzNameCollisionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzNameCollisionTest.java?rev=1067615&r1=1067614&r2=1067615&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzNameCollisionTest.java
(original)
+++ camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzNameCollisionTest.java
Sun Feb  6 08:49:18 2011
@@ -56,6 +56,28 @@ public class QuartzNameCollisionTest {
 
 
     /**
+     * Don't check for a name collision if the job is stateful.
+     */
+    @Test
+    public void testNoStatefulCollisionError() throws Exception {
+        camel1 = new DefaultCamelContext();
+        camel1.setName("camel-1");
+        camel1.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz://myGroup/myTimerName?stateful=true&cron=0/1+*+*+*+*+?").to("log:one",
"mock:one");
+            }
+        });
+        camel1.start();
+
+        camel2 = new DefaultCamelContext();
+        QuartzComponent component2 = new QuartzComponent(camel2);
+
+        component2.createEndpoint("quartz://myGroup/myTimerName?stateful=true");
+        // if no exception is thrown then this test passed.
+    }
+
+    /**
      * Make sure a resume doesn't trigger a dupe name error.
      */
     @Test



Mime
View raw message