java - How to query the scheduled jobs from Quartz scheduler? -
i have scheduler
object in application , add job
s using schedulejob
method.
in code schedule job
s instant trigger
:
triggerbuilder.newtrigger().startnow().build();
my question how tell job
s scheduled scheduler
? there getcurrentlyexecutingjobs
method seems unreliable far.
the below code list quartz job associated scheduler (quartz 2.x.x)
for (string groupname : scheduler.getjobgroupnames()) { (jobkey jobkey : scheduler.getjobkeys(groupmatcher.jobgroupequals(groupname))) { string jobname = jobkey.getname(); string jobgroup = jobkey.getgroup(); //get job's trigger list<trigger> triggers = (list<trigger>) scheduler.gettriggersofjob(jobkey); date nextfiretime = triggers.get(0).getnextfiretime(); system.out.println("[jobname] : " + jobname + " [groupname] : " + jobgroup + " - " + nextfiretime); } }
Comments
Post a Comment