How to Kill A Job Once it's Triggered in the Queue?
I have a job in AEM that implements JobConsumer interface. My questions are:
1. Once it's triggered but not running yet, how to kill the job?
2. Once it's running, how to kill the job?
I saw JobConsumer interface has `cancel` method but I am not sure how to use it. I found an example online and it's not using cancel() in the exception clause:
@Overridepublic JobResult process(Job job) {
try {
logger.debug("Processing the JOB *******");
//A Property map will be passed on so we can fetch the values we need here to//Process the request
String path = (String) job.getProperty("path");
logger.debug("The path in which the replication is triggered and passed to the Job is " +
"{}", path);
//TODO : Write your business logic here . Any properties you need to execute the job can be passed//TODO: on via the Map which is treated as the properties for the JOB.
/**
* Return the proper JobResult based on the work done...
*
* > OK : Processed successfully
* > FAILED: Processed unsuccessfully and reschedule --> This will keep the JOB up for next retry
* > CANCEL: Processed unsuccessfully and do NOT reschedule
* > ASYNC: Process through the JobConsumer.AsyncHandler interface
*/return JobConsumer.JobResult.OK;
} catch (Exception e) {
logger.error("Exception is ", e);
return JobResult.FAILED;
}
}
}