Reputation: 23587
I am trying to fetch all jobs registered with the Quartz scheduler for a particular group. here is my piece of code
CustomSchdularFactory.getSchedulerInstance().getJobKeys(groupEquals(group));
here group
is a String variable holding the name of group whose associated jobs i want to fetch.
while using the above code i am getting following error
The method getJobKeys(GroupMatcher<JobKey>) in the type Scheduler is not applicable for the arguments (GroupMatcher<Key<Key<T>>>)
i am not sure why this error is occurring as i took the reference from Quartz official documents
Upvotes: 4
Views: 7807
Reputation: 21
On Quartz.NET 3.0, I was able to get this working in asynchronous mode:
public static async Task RunTask() {
StdSchedulerFactory factory = new StdSchedulerFactory(System.Configuration.ConfigurationManager.AppSettings);
IScheduler scheduler = await factory.GetScheduler();
await scheduler.Start();
IReadOnlyCollection<string> jgn = await sch.GetJobGroupNames(new System.Threading.CancellationToken());
foreach (string jno in jgn)
{
IReadOnlyCollection <JobKey> jk = await sch.GetJobKeys(jobGroupEquals(jno));
foreach (JobKey j in jk)
{
var currentJob = await sch.GetJobDetail(j);
//print the properties of the current job
Console.WriteLine(currentJob.Key.Name);
Console.WriteLine(currentJob.Description);
}
}
}
private static GroupMatcher<JobKey> jobGroupEquals(string jno)
{
return GroupMatcher<JobKey>.GroupEquals(jno);
}
Upvotes: 0
Reputation: 41
Use it
Scheduler sched = new StdSchedulerFactory().getScheduler();
for(String group: sched.getJobGroupNames()) {
for(JobKey jobKey : sched.getJobKeys(GroupMatcher.jobGroupEquals(group))) {
...
}
}
Upvotes: 3
Reputation: 76
Use jobGroupEquals instead of groupEquals
CustomSchdularFactory.getSchedulerInstance().getJobKeys(jobGroupEquals(group));
and it will work for you.
Upvotes: 6