Getting only one trigger details from qrtztrigger table

Hello,

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)

I have written code in Java inside a :

public void execute(JobExecutionContext context) throws JobExecutionException {
Trigger trigger = context.getTrigger();
}

In trigger, i should get two values , both : 92caa011-1575-42d5-bda6-0c8cdfeba03f, d21422e9-35b4-4c7c-9ed6-c7dcaa78e193

Also,getting only cron from the following code.

if (trigger instanceof CronTriggerImpl) {
CronTriggerImpl cronTrigger = (CronTriggerImpl) trigger;
cronExpression = cronTrigger.getCronExpression();
log.info(“Cron in batch sms job :” + cronExpression);
}

but I am getting only one value i.e. d21422e9-35b4-4c7c-9ed6-c7dcaa78e193 and its respective cron expression.

Kindly help with this like how can i get both the trigger name values and its respective cron expressions.

PFA artifacts
Screenshot (186)
Screenshot (184)
Screenshot (183)

Hello Suprita.

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?

Regard,
Ivan