This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit ca2456645321f1b8c26d8ca1ddf1b1f8b49596ad Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Jan 6 09:47:20 2022 +0100 CAMEL-17440: camel-quartz - Remove startDelayed option as it does not work properly and causes problems. --- .../quartz/QuartzComponentConfigurer.java | 6 --- .../org/apache/camel/component/quartz/quartz.json | 3 +- .../camel/component/quartz/QuartzComponent.java | 47 +++------------------ .../quartz/QuartzCronRouteFireNowTest.java | 2 +- .../quartz/QuartzStartDelayedOptionTest.java | 46 --------------------- .../component/quartz/QuartzStartDelayedTest.java | 48 ---------------------- .../QuartzStartDelayedWithReferenceTest.java | 44 -------------------- 7 files changed, 7 insertions(+), 189 deletions(-) diff --git a/components/camel-quartz/src/generated/java/org/apache/camel/component/quartz/QuartzComponentConfigurer.java b/components/camel-quartz/src/generated/java/org/apache/camel/component/quartz/QuartzComponentConfigurer.java index 03c7676..a9027c2 100644 --- a/components/camel-quartz/src/generated/java/org/apache/camel/component/quartz/QuartzComponentConfigurer.java +++ b/components/camel-quartz/src/generated/java/org/apache/camel/component/quartz/QuartzComponentConfigurer.java @@ -43,8 +43,6 @@ public class QuartzComponentConfigurer extends PropertyConfigurerSupport impleme case "scheduler": target.setScheduler(property(camelContext, org.quartz.Scheduler.class, value)); return true; case "schedulerfactory": case "schedulerFactory": target.setSchedulerFactory(property(camelContext, org.quartz.SchedulerFactory.class, value)); return true; - case "startdelayedseconds": - case "startDelayedSeconds": target.setStartDelayedSeconds(property(camelContext, int.class, value)); return true; default: return false; } } @@ -74,8 +72,6 @@ public class QuartzComponentConfigurer extends PropertyConfigurerSupport impleme case "scheduler": return org.quartz.Scheduler.class; case "schedulerfactory": case "schedulerFactory": return org.quartz.SchedulerFactory.class; - case "startdelayedseconds": - case "startDelayedSeconds": return int.class; default: return null; } } @@ -106,8 +102,6 @@ public class QuartzComponentConfigurer extends PropertyConfigurerSupport impleme case "scheduler": return target.getScheduler(); case "schedulerfactory": case "schedulerFactory": return target.getSchedulerFactory(); - case "startdelayedseconds": - case "startDelayedSeconds": return target.getStartDelayedSeconds(); default: return null; } } diff --git a/components/camel-quartz/src/generated/resources/org/apache/camel/component/quartz/quartz.json b/components/camel-quartz/src/generated/resources/org/apache/camel/component/quartz/quartz.json index ce98abe..94d93ac 100644 --- a/components/camel-quartz/src/generated/resources/org/apache/camel/component/quartz/quartz.json +++ b/components/camel-quartz/src/generated/resources/org/apache/camel/component/quartz/quartz.json @@ -33,8 +33,7 @@ "scheduler": { "kind": "property", "displayName": "Scheduler", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.quartz.Scheduler", "deprecated": false, "autowired": false, "secret": false, "description": "To use the custom configured Quartz scheduler, instead of creating a new Scheduler." }, "schedulerFactory": { "kind": "property", "displayName": "Scheduler Factory", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.quartz.SchedulerFactory", "deprecated": false, "autowired": false, "secret": false, "description": "To use the custom SchedulerFactory which is used to create the Scheduler." }, "autoStartScheduler": { "kind": "property", "displayName": "Auto Start Scheduler", "group": "scheduler", "label": "scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the scheduler should be auto started. <p\/> This options is default true" }, - "interruptJobsOnShutdown": { "kind": "property", "displayName": "Interrupt Jobs On Shutdown", "group": "scheduler", "label": "scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to interrupt jobs on shutdown which forces the scheduler to shutdown quicker and attempt to interrupt any running jobs. If this is enabled then any running jobs can fail due to being i [...] - "startDelayedSeconds": { "kind": "property", "displayName": "Start Delayed Seconds", "group": "scheduler", "label": "scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "Seconds to wait before starting the quartz scheduler." } + "interruptJobsOnShutdown": { "kind": "property", "displayName": "Interrupt Jobs On Shutdown", "group": "scheduler", "label": "scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to interrupt jobs on shutdown which forces the scheduler to shutdown quicker and attempt to interrupt any running jobs. If this is enabled then any running jobs can fail due to being i [...] }, "properties": { "groupName": { "kind": "path", "displayName": "Group Name", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Camel", "description": "The quartz group name to use. The combination of group name and trigger name should be unique." }, diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java index 9c43e28..ceb13e6 100644 --- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java +++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java @@ -69,8 +69,6 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup private Map properties; @Metadata private String propertiesFile; - @Metadata(label = "scheduler") - private int startDelayedSeconds; @Metadata(label = "scheduler", defaultValue = "true") private boolean autoStartScheduler = true; @Metadata(label = "scheduler") @@ -102,17 +100,6 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup this.autoStartScheduler = autoStartScheduler; } - public int getStartDelayedSeconds() { - return startDelayedSeconds; - } - - /** - * Seconds to wait before starting the quartz scheduler. - */ - public void setStartDelayedSeconds(int startDelayedSeconds) { - this.startDelayedSeconds = startDelayedSeconds; - } - public boolean isPrefixJobNameWithEndpointId() { return prefixJobNameWithEndpointId; } @@ -377,22 +364,10 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - // Get couple of scheduler settings - Integer startDelayedSeconds = getAndRemoveParameter(parameters, "startDelayedSeconds", Integer.class); - if (startDelayedSeconds != null) { - if (this.startDelayedSeconds != 0 && !(this.startDelayedSeconds == startDelayedSeconds)) { - LOG.warn("A Quartz job is already configured with a different 'startDelayedSeconds' configuration! " - + "All Quartz jobs must share the same 'startDelayedSeconds' configuration! Cannot apply the 'startDelayedSeconds' configuration!"); - } else { - this.startDelayedSeconds = startDelayedSeconds; - } - } - Boolean autoStartScheduler = getAndRemoveParameter(parameters, "autoStartScheduler", Boolean.class); if (autoStartScheduler != null) { this.autoStartScheduler = autoStartScheduler; } - Boolean prefixJobNameWithEndpointId = getAndRemoveParameter(parameters, "prefixJobNameWithEndpointId", Boolean.class); if (prefixJobNameWithEndpointId != null) { this.prefixJobNameWithEndpointId = prefixJobNameWithEndpointId; @@ -408,9 +383,6 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup result.setTriggerKey(triggerKey); result.setTriggerParameters(triggerParameters); result.setJobParameters(jobParameters); - if (startDelayedSeconds != null) { - result.setStartDelayedSeconds(startDelayedSeconds); - } if (autoStartScheduler != null) { result.setAutoStartScheduler(autoStartScheduler); } @@ -551,22 +523,13 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup // Now scheduler is ready, let see how we should start it. if (!autoStartScheduler) { - LOG.info("Not starting scheduler because autoStartScheduler is set to false."); + LOG.info("Not starting scheduler because autoStartScheduler is set to false"); } else { - if (startDelayedSeconds > 0) { - if (scheduler.isStarted()) { - LOG.warn("The scheduler has already started. Cannot apply the 'startDelayedSeconds' configuration!"); - } else { - LOG.info("Starting scheduler with startDelayedSeconds={}", startDelayedSeconds); - scheduler.startDelayed(startDelayedSeconds); - } + if (scheduler.isStarted()) { + LOG.info("The scheduler has already been started"); } else { - if (scheduler.isStarted()) { - LOG.info("The scheduler has already been started."); - } else { - LOG.info("Starting scheduler."); - scheduler.start(); - } + LOG.info("Starting scheduler"); + scheduler.start(); } } } diff --git a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzCronRouteFireNowTest.java b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzCronRouteFireNowTest.java index c8e77ea..45f24da 100644 --- a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzCronRouteFireNowTest.java +++ b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzCronRouteFireNowTest.java @@ -41,7 +41,7 @@ public class QuartzCronRouteFireNowTest extends BaseQuartzTest { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() throws SchedulerException { - // daily trigger strarted a day ago + // daily trigger started a day ago from("quartz://daily?triggerStartDelay=" + TimeUnit.DAYS.toMillis(-1L) + "&cron=0+0+0+*+*+?") .to("log:quartz") .to("mock:result"); diff --git a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedOptionTest.java b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedOptionTest.java deleted file mode 100644 index 4483eb9..0000000 --- a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedOptionTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.quartz; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.jupiter.api.Test; - -public class QuartzStartDelayedOptionTest extends BaseQuartzTest { - - @Test - public void testStartDelayed() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.setResultMinimumWaitTime(1500); - mock.setResultWaitTime(3000); - mock.expectedMessageCount(2); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("quartz://myGroup/myTimerName?startDelayedSeconds=2&trigger.repeatInterval=2&trigger.repeatCount=1") - .routeId("myRoute") - .to("mock:result"); - } - }; - } -} diff --git a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedTest.java b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedTest.java deleted file mode 100644 index ad7837b..0000000 --- a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.quartz; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.jupiter.api.Test; - -public class QuartzStartDelayedTest extends BaseQuartzTest { - - @Test - public void testStartDelayed() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.setResultMinimumWaitTime(1900); - mock.setResultWaitTime(3000); - mock.expectedMessageCount(2); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - QuartzComponent quartz = context.getComponent("quartz", QuartzComponent.class); - quartz.setStartDelayedSeconds(2); - - from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1").routeId("myRoute") - .to("mock:result"); - } - }; - } -} diff --git a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedWithReferenceTest.java b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedWithReferenceTest.java deleted file mode 100644 index 5d88037..0000000 --- a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStartDelayedWithReferenceTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.quartz; - -import org.apache.camel.BindToRegistry; -import org.apache.camel.builder.RouteBuilder; - -public class QuartzStartDelayedWithReferenceTest extends QuartzStartDelayedTest { - - @BindToRegistry("interval") - private Long interval = Long.valueOf(2); - - @BindToRegistry("count") - private Integer count = Integer.valueOf(1); - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - QuartzComponent quartz = context.getComponent("quartz", QuartzComponent.class); - quartz.setStartDelayedSeconds(2); - - from("quartz://myGroup/myTimerName?trigger.repeatInterval=#interval&trigger.repeatCount=#count") - .routeId("myRoute").to("mock:result"); - } - }; - } - -}