Hazelcast scheduling Cron jobs - java

Can anybody help me with scheduling cron jobs with a help of Hazelcast? I know that Hazelcast has IScheduledExecutorService, but I can't find a way to schedule cron task (only delayed or interval jobs).

Hazelcast doesn't have that kind of functionality. You need to use a 3rd party system like quartz scheduler.

Related

Need to update cron expressed timer on runtime in camel quartz

I need to update camel quartz cron based timer dynamically on runtime.
The timer cron expression is mentioned in DB and accordingly my scheduler is working and suppose it is 10 minutes interval.
Now if I update timer cron expression in DB(updated to 20 minutes interval), I am trying to update the cron expression in camel side which should run 20 minutes interval instead of 10 mins interval but not reflecting.
I have gone through couple of links but could not get much help:
Camel runtime timer change
https://issues.apache.org/jira/browse/CAMEL-7153
Any guidance or example will be great to understand. Advance thanks.
If Camel does not provide such solution, which library will be best suitable for such use case. I have few in minds like (Java Timer, Spring Scheduler, Quartz Scheduler) and I feel these provides such provision.

Quartz Persistent Jobs mis-fire recovery using JDBC JobStore

I am implementing Quartz scheduler with JDBC JobStore in Spring. I have a use case, where if my application crashes and it has jobs to be executed within time frame between the crash and restart of the scheduler. My approach is to compare nextExecutionTime for all jobs with the current time at startup of the scheduler and if the nextExecutionTime is less than the current time, execute the job.
But I have a strong notion that there is a nicer way to get this job done. Either supported by Quartz or already implemented by someone. Can you suggest a better approach for this?
Does the misfire instruction feature do what you want? See the tutorial at Quartz Tutorial Lesson 4 and more specifically Example - Job Misfires You probably need to call withMisfireHandlingInstructionFireNow() when you build your trigger.

Can quartz share same JOB between different nodes in clustered environment?

I am using Quartz in my Spring web application.
I successfully configured everything in cluster environment where quartz will pick its JOBS firing properly.
Now one of my JOB is big and will take so much resource and time. So can i share the JOB between nodes so that same JOB is executed on two nodes in a clustered way, Not different triggers ?
Or there any other ways to achieve this ?
Thanks
Quartz provides feature to trigger jobs. What you do inside in not quartz's responsibility.
Depending upon what your job is doing you can look to divide into smaller jobs and then cluster will help.
If you provide more info then we can help.

Quartz scheduler - Is it possible to configure Quartz to allow jobs with the same identification in RAMJobStore?

I'm using Quartz together with Spring. The JobStore that I'm using is the RAMJobStore.
I create a couple of jobs with the same identification (they have the same instance definition (JobDetail)). Because I want to make sure that these jobs aren't executed in parallel, I annotated their job class with #DisallowConcurrentExecution.
My problem is that the RAMJobStore doesn't allow more than one job with the same identification in the same time in the store, so when I try to add the job I get the exception:
org.quartz.ObjectAlreadyExistsException: Unable to store Job :
'jobX', because one already exists with this identification.
Do you have any idea about how I can overcome this problem?
Thanks a lot!
If you have two different jobs that are running on two different triggers, then I'm not aware of any Quartz annotations that would prevent the two jobs from running in parallel. You could reference the Scheduler instance in each of the jobs to determine if the other job is executing. Then you could pause or reschedule jobs to prevent them from running in parallel.
It is clear from the RAMJobStore source code that there can't be two jobs with the same key in the same time in the RAMJobStore.
Have a look here at the source code.

How to schedule multiple jobs in quartz scheduler using same trigger?

I am using quartz scheduler in my spring project. I have to run a job after another job which is scheduled to run in every 15 mins? I cant run this job concurrently as both of this jobs have to access same mail account using different protocols(one to send:smtp and other to receive: imap) and it may cause problems. Please reply quickly, as its an urgent requirement.
Just write a wrapper job class that launches second job after the first. You could then reuse separate jobs in the future if there will be any necessity.
You could do something with writing a job listener to recognize when the first job ends, and have it start the second. But the solution first suggested by mindas is easier - wrap both your jobs in another Job implementation, which is the one you actually schedule.

Categories

Resources