Quartz clustering on a camel spring DSL

I am trying to execute a "restore request " in a crash scenario on two different machines with their clocks in sync.

My configuration is as below:

step 1: camel-context.xml

I have defined the below route in camel-context.xml file.

<route id="quartz" trace="true">
  <from uri="quartz2://cluster/quartz?cron=0+0/2+++*+?&durableJob=true&stateful=true&recoverableJob=true">
<route>

      

Step 2: quartz.properties:

I have included

org.quartz.jobStore.isClustered = true
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.instanceName =ClusteredScheduler

      

I am currently running the same camel app in two different instances in my local mode and clustering is working fine. But when I try to check the "restore request" I get below the exception.

An exception:

[QuartzScheduler_ClusteredScheduler-camelContext-16308243724_ClusterManager] INFO org.quartz.impl.jdbcjobstore.JobStoreTX - ClusterManager: detected 1 failed or restarted instances.
[QuartzScheduler_ClusteredScheduler-camelContext-16308243724_ClusterManager] INFO org.quartz.impl.jdbcjobstore.JobStoreTX - ClusterManager: Scanning for instance "6308270818" failed in-progress jobs.
[QuartzScheduler_ClusteredScheduler-camelContext-16308243724_ClusterManager] INFO org.quartz.impl.jdbcjobstore.JobStoreTX - ClusterManager: ......Scheduled 1 recoverable job(s) for recovery.
[ClusteredScheduler-camelContext_Worker-1] WARN org.apache.camel.component.quartz2.CamelJob - Cannot find existing QuartzEndpoint with uri: quartz2://cluster/quartz?cron=0+0%2F2+*+*+*+%3F&durableJob=true&recoverableJob=true&stateful=true. Creating new endpoint instance.
[ClusteredScheduler-camelContext_Worker-1] ERROR org.apache.camel.component.quartz2.CamelJob - Failed to execute CamelJob.
**org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: quartz2://cluster/quartz?cron=0+0%2F2+*+*+*+%3F&durableJob=true&recoverableJob=true&stateful=true due to: Trigger key cluster.quartz is already in used by Endpoint[quartz2://cluster/quartz?cron=0+0%2F2+*+*+*+%3F&durableJob=true&recoverableJob=true&stateful=true]**
      at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:545)
      at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:558)
      at org.apache.camel.component.quartz2.CamelJob.lookupQuartzEndpoint(CamelJob.java:123)
      at org.apache.camel.component.quartz2.CamelJob.execute(CamelJob.java:49)
      at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
      at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.IllegalArgumentException: Trigger key cluster.quartz is already in used by Endpoint[quartz2://cluster/quartz?cron=0+0%2F2+*+*+*+%3F&durableJob=true&recoverableJob=true&stateful=true]
      at org.apache.camel.component.quartz2.QuartzEndpoint.ensureNoDupTriggerKey(QuartzEndpoint.java:272)
      at org.apache.camel.component.quartz2.QuartzEndpoint.addJobInScheduler(QuartzEndpoint.java:254)
      at org.apache.camel.component.quartz2.QuartzEndpoint.doStart(QuartzEndpoint.java:202)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
      at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2158)
      at org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1016)
      at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:977)
      at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:973)
      at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:541)
      ... 5 more

      

After instance 1 is closed, which is currently discarding the job, instance 2 tries to immediately recover the job, but does not execute the job. It selects the same job in the next interval (this is normal).

My requirement is for an active node to immediately recover the failed job.

Thanks in advance.

+3


source to share


1 answer


I think that we can avoid the assurance check of theNoDupTriggerKey if the recoverableJob is true. I just created JIRA CAMEL-8076 for this.



+1


source







All Articles