Sunday 1 April 2018

OIM API - Code Snippet to Check Scheduled Job Status for the given Scheduled Job.

For checking if scheduled job is running?

public boolean isScheduledJobRunning(String jobName){
    final String logp = CN + " :: isScheduledJobRunning - ";
    LOGGER.debug(logp + "START");
    SchedulerService schedulerService = null;
    boolean result = false;
   
    if (null == jobName || jobName.trim().length() == 0){
        return false;
    }
    jobName = jobName.trim();
   
    try {
        //get scheduler service
        schedulerService = Platform.getService(SchedulerService.class);
       
        int status = schedulerService.getStatusOfJob(jobName);
        LOGGER.info(logp + "Status for job name " + jobName + " = " + status);

        if (status == 5) {
            result = true;
        }
    } catch (Exception e) {
        LOGGER.error(logp + "Exception while checking the schedule job status");
    }
    LOGGER.debug(logp + "END");
    return result;
}



For checking if scheduled job is started?

public boolean isScheduledJobStarted(String jobName) {
    final String logp = CN + "::isScheduledJobRunning - ";
    LOGGER.debug(logp + "START");
    SchedulerService schedulerService = null;
    boolean result = false;
   
    if (null == jobName || jobName.trim().length() == 0) {
        return false;
    }
   
    jobName = jobName.trim();

    try{
        //get scheduler service
        schedulerService = Platform.getService(SchedulerService.class);
       
        int status = schedulerService.getStatusOfJob(jobName);
        LOGGER.info(logp + "Status for job name " + jobName + " = " + status);

        if (status == 2) {
            result = true;
        }
    }catch(Exception e){
        LOGGER.error(logp + "Exception while checking the schedule job status");
    }
    LOGGER.debug(logp + "END");
    return result;
}


Happy Learning!!!

No comments:

Post a Comment