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 2025/08/29 11:49:12 UTC
(camel) branch main updated: CAMEL-22387: camel-quartz - Should be suspendable so no new jobs is triggered while camel is shutting down (#19040)
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
The following commit(s) were added to refs/heads/main by this push:
new 3bdf5496a74 CAMEL-22387: camel-quartz - Should be suspendable so no new jobs is triggered while camel is shutting down (#19040)
3bdf5496a74 is described below
commit 3bdf5496a74174dc50e0e5f726adb45f3c005119
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 29 13:49:06 2025 +0200
CAMEL-22387: camel-quartz - Should be suspendable so no new jobs is triggered while camel is shutting down (#19040)
---
.../java/org/apache/camel/component/quartz/CamelJob.java | 8 ++++----
.../org/apache/camel/component/quartz/QuartzConsumer.java | 14 +++++++++++++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
index 4587513c6e1..d4913eb43ec 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
@@ -52,6 +52,8 @@ public class CamelJob implements Job, InterruptableJob {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
+ LOG.debug("Triggering job instance id: {}", context.getFireInstanceId());
+
Exchange exchange = null;
try {
if (hasTriggerExpired(context)) {
@@ -99,14 +101,12 @@ public class CamelJob implements Job, InterruptableJob {
}
throw new JobExecutionException(e);
}
+
+ LOG.debug("Completed job instance id: {}", context.getFireInstanceId());
}
/**
* Validates if the Fire Time lies within the Start Time and End Time
- *
- * @param context
- *
- * @return
*/
private boolean hasTriggerExpired(JobExecutionContext context) {
Date fireTime = context.getFireTime();
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java
index e61d301eb16..ea29bb4ac96 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java
@@ -18,13 +18,14 @@ package org.apache.camel.component.quartz;
import org.apache.camel.Endpoint;
import org.apache.camel.Processor;
+import org.apache.camel.Suspendable;
import org.apache.camel.support.DefaultConsumer;
/**
* This consumer process QuartzMessage when scheduler job is executed per scheduled time. When the job runs, it will
* call this consumer's processor to process a new exchange with QuartzMessage.
*/
-public class QuartzConsumer extends DefaultConsumer {
+public class QuartzConsumer extends DefaultConsumer implements Suspendable {
public QuartzConsumer(Endpoint endpoint, Processor processor) {
super(endpoint, processor);
@@ -47,4 +48,15 @@ public class QuartzConsumer extends DefaultConsumer {
super.doStop();
}
+ @Override
+ protected void doSuspend() throws Exception {
+ super.doSuspend();
+ getEndpoint().onConsumerStop(this);
+ }
+
+ @Override
+ protected void doResume() throws Exception {
+ super.doResume();
+ getEndpoint().onConsumerStart(this);
+ }
}