I have scheduled a campaign which have 2 cron expressions, lets say( 0 14 15 26 6 ? and 0 14 15 3 7 ?) and it created 2 triggers also : (92caa011-1575-42d5-bda6-0c8cdfeba03f, d21422e9-35b4-4c7c-9ed6-c7dcaa78e193)
JobExecutionContext represents context of the current execution.
So Trigger trigger = context.getTrigger(); should return you single trigger - the one that has been fired and caused this execution. It works as intended.
If you want to get all the triggers for some specific job you need to use Scheduler. It can be autowired to some Spring bean or it can be acquired from the JobExecutionContext:
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
// acquire Scheduler
Scheduler scheduler = context.getScheduler();
// acquire key of current job
JobKey jobKey = context.getJobDetail().getKey();
try {
// Get all triggers that are associated with job with provided key
List<? extends Trigger> allJobTriggers = scheduler.getTriggersOfJob(jobKey);
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
}
Also, can you provide information about what you want to achieve by getting all job triggers within execution of one of them?