You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/09/06 05:16:38 UTC

[camel] branch main updated (2e8d09200bb -> eb9e7247b58)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 2e8d09200bb CAMEL-18121: Upgrade to Kafka 3.2.1 (#8286)
     new f7dc63fcdd7 Polished
     new eb9e7247b58 CAMEL-18143: camel-quartz - Quartz scheduler should be autowired on component.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../quartz/QuartzComponentConfigurer.java          |  5 ++++
 .../org/apache/camel/component/quartz/quartz.json  |  2 +-
 .../camel/component/quartz/QuartzComponent.java    | 28 ++++++++++++----------
 .../apache/camel/main/http/VertxHttpServer.java    |  1 -
 4 files changed, 21 insertions(+), 15 deletions(-)


[camel] 02/02: CAMEL-18143: camel-quartz - Quartz scheduler should be autowired on component.

Posted by da...@apache.org.
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 eb9e7247b58cc54b5e943f0c0974c9e8c06476ef
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 6 07:15:58 2022 +0200

    CAMEL-18143: camel-quartz - Quartz scheduler should be autowired on component.
---
 .../quartz/QuartzComponentConfigurer.java          |  5 ++++
 .../org/apache/camel/component/quartz/quartz.json  |  2 +-
 .../camel/component/quartz/QuartzComponent.java    | 28 ++++++++++++----------
 3 files changed, 21 insertions(+), 14 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 a9027c21b6b..1954f2530e1 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
@@ -47,6 +47,11 @@ public class QuartzComponentConfigurer extends PropertyConfigurerSupport impleme
         }
     }
 
+    @Override
+    public String[] getAutowiredNames() {
+        return new String[]{"scheduler"};
+    }
+
     @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
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 17aa65e0865..88918eee244 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
@@ -30,7 +30,7 @@
     "propertiesFile": { "kind": "property", "displayName": "Properties File", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "File name of the properties to load from the classpath" },
     "propertiesRef": { "kind": "property", "displayName": "Properties Ref", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "References to an existing Properties or Map to lookup in the registry to use for configuring quartz." },
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
-    "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." },
+    "scheduler": { "kind": "property", "displayName": "Scheduler", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.quartz.Scheduler", "deprecated": false, "autowired": true, "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. 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 [...]
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 a9ae00ca267..b4246b14796 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
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * This component will hold a Quartz Scheduler that will provide scheduled timer based endpoint that generate a
- * QuartzMessage to a route. Currently it support Cron and Simple trigger scheduling type.
+ * QuartzMessage to a route.
  */
 @Component("quartz")
 public class QuartzComponent extends DefaultComponent implements ExtendedStartupListener {
@@ -59,8 +59,9 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup
 
     private final List<SchedulerInitTask> schedulerInitTasks = new ArrayList<>();
     private volatile boolean schedulerInitTasksDone;
+    private volatile boolean shouldStopScheduler;
 
-    @Metadata(label = "advanced")
+    @Metadata(label = "advanced", autowired = true)
     private Scheduler scheduler;
     @Metadata(label = "advanced")
     private SchedulerFactory schedulerFactory;
@@ -242,7 +243,7 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup
             // enable jmx unless configured to not do so
             if (enableJmx && !prop.containsKey("org.quartz.scheduler.jmx.export")) {
                 prop.put("org.quartz.scheduler.jmx.export", "true");
-                LOG.info("Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX.");
+                LOG.info("Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX");
             }
 
             answer = new StdSchedulerFactory(prop);
@@ -284,7 +285,7 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup
             // enable jmx unless configured to not do so
             if (enableJmx && !prop.containsKey("org.quartz.scheduler.jmx.export")) {
                 prop.put("org.quartz.scheduler.jmx.export", "true");
-                LOG.info("Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX.");
+                LOG.info("Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX");
             }
 
             answer = new StdSchedulerFactory(prop);
@@ -463,7 +464,8 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup
     }
 
     private void createAndInitScheduler() throws SchedulerException {
-        LOG.info("Create and initializing scheduler.");
+        LOG.debug("Creating and initializing Quartz scheduler");
+        shouldStopScheduler = true;
         scheduler = createScheduler();
 
         SchedulerContext quartzContext = storeCamelContextInQuartzContext();
@@ -477,7 +479,7 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup
         // Store CamelContext into QuartzContext space
         SchedulerContext quartzContext = scheduler.getContext();
         String camelContextName = QuartzHelper.getQuartzContextName(getCamelContext());
-        LOG.debug("Storing camelContextName={} into Quartz Context space.", camelContextName);
+        LOG.debug("Storing camelContextName={} into Quartz Context space", camelContextName);
         quartzContext.put(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + camelContextName, getCamelContext());
         return quartzContext;
     }
@@ -490,18 +492,18 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup
     protected void doStop() throws Exception {
         super.doStop();
 
-        if (scheduler != null) {
+        if (scheduler != null && shouldStopScheduler) {
             if (isInterruptJobsOnShutdown()) {
-                LOG.info("Shutting down scheduler. (will interrupts jobs to shutdown quicker.)");
+                LOG.info("Shutting down Quartz scheduler (will interrupts jobs to shutdown quicker)");
                 scheduler.shutdown(false);
                 scheduler = null;
             } else {
                 AtomicInteger number = (AtomicInteger) scheduler.getContext().get(QuartzConstants.QUARTZ_CAMEL_JOBS_COUNT);
                 if (number != null && number.get() > 0) {
-                    LOG.info("Cannot shutdown scheduler: {} as there are still {} jobs registered.",
+                    LOG.info("Cannot shutdown Quartz scheduler: {} as there are still {} jobs registered",
                             scheduler.getSchedulerName(), number.get());
                 } else {
-                    LOG.info("Shutting down scheduler. (will wait for all jobs to complete first.)");
+                    LOG.info("Shutting down Quartz scheduler (will wait for all jobs to complete first)");
                     scheduler.shutdown(true);
                     scheduler = null;
                 }
@@ -543,12 +545,12 @@ 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 Quartz scheduler: {} because autoStartScheduler is set to false", scheduler);
         } else {
             if (scheduler.isStarted()) {
-                LOG.info("The scheduler has already been started");
+                LOG.info("The Quartz scheduler: {} has already been started", scheduler);
             } else {
-                LOG.info("Starting scheduler");
+                LOG.info("Starting Quartz scheduler: {}", scheduler);
                 scheduler.start();
             }
         }


[camel] 01/02: Polished

Posted by da...@apache.org.
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 f7dc63fcdd7fa1c8c1383c4fb6e03100aa5576d5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 6 07:08:42 2022 +0200

    Polished
---
 .../src/main/java/org/apache/camel/main/http/VertxHttpServer.java        | 1 -
 1 file changed, 1 deletion(-)

diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/http/VertxHttpServer.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/http/VertxHttpServer.java
index b1d20a26870..a9b6ad6685d 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/http/VertxHttpServer.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/http/VertxHttpServer.java
@@ -143,7 +143,6 @@ public final class VertxHttpServer {
                             if (last == null || last.size() != endpoints.size() || !last.containsAll(endpoints)) {
                                 LOG.info("HTTP endpoints summary");
                                 for (HttpEndpointModel u : endpoints) {
-                                    String v = u.getVerbs();
                                     String line = "http://0.0.0.0:" + port + u.getUri();
                                     if (u.getVerbs() != null) {
                                         line += " (" + u.getVerbs() + ")";