quarkus-quickstarts
quarkus-quickstarts copied to clipboard
Quartz Quickstart - "client style" scheduler Question
Hello,
I'm playing around with quickstarts but I don't get how to get what I want. I'd like to create a Quartz Cluster with (say...) 3 nodes and I want them to fire triggers and execute jobs. So far so good. Then I'd like to add an "external client" which can ONLY schedule jobs within that cluster, but not execute jobs.
Is that possibile? Should I switch to non clustered mode?
Thanks in advance!
Hello,
i found a working solution and I'd like your opinion: i'm using Kafka... I merged kafka quickstart and quartz quickstart
- I register a startup event and programmatically create a job and a trigger to start after a year and repeat yearly
- I consume a kafka topic and trigger the job
It works fine, but I have a couple questions
- Is it possible to create non-auto-firing schedule? In my example I create a yearly schedule and it's not a clean solution.
- Can I obtain some ID of my trigger to check the status of my job in a later moment?
- Have I missed a simpler alternative to that one? I would not use RMI btw...
@Inject
org.quartz.Scheduler quartz;
void onStart(@Observes StartupEvent event) throws SchedulerException {
if (quartz.getJobGroupNames().contains("on-demand")) {
// in dev mode, the schedule would be registered twice, so I check it.
return;
}
JobDetail job = JobBuilder.newJob(MyJob.class)
.withIdentity("requested-job", "on-demand")
.build();
Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity("myTrigger", "myGroup")
.startAt(new Date(System.currentTimeMillis() + 365 * 86400 * 1000)) // start after a year
.withSchedule(SimpleScheduleBuilder.repeatHourlyForever(365*24)) // repeat yearly
.build();
quartz.scheduleJob(job, trigger);
}
@Incoming("requests")
@Blocking
public void process(String request) throws SchedulerException {
JobKey key = new JobKey("requested-job", "on-demand");
quartz.triggerJob(key);
}