Create a Cron Using Cron Expressions

Use this SDK to implement crons to schedule the submission of jobs to job pools. However, the configuration of the cron will be defined using regex-like expressions called Cron Expressions.

Note: In the following SDK, the cron has been configured using Cron Expressions, to submit a job to the job pool on 0Hrs 0Mins 0Secs on every 1st day of the week on the 1st month of every year.

Ensure the following packages have been imported:

    
copy
import com.zc.component.jobscheduling.beans.cron.ZCCronDetails; import com.zc.component.jobscheduling.beans.cron.ZCCronBuilder; import com.zc.component.jobscheduling.beans.job.ZCJobBuilder; import com.zc.component.jobscheduling.beans.job.ZCJobMetaDetail; import org.json.simple.JSONObject;
    
copy
// generate function job meta ZCJobMetaDetail jobMeta = ZCJobBuilder.functionJobBuilder() // get function job builder .setJobConfig(2, 15 * 60 l) // set job config - job retries => 2 retries in 15 mins (optional) .setJobpoolName("functions_jobpool") // set the name of the function jobpool (optional) (either jobpoolId or jobpoolName is mandatory) // .setJobpoolId(1234567890L) // set the Id of the function jobpool (optional) (either jobpoolId or jobpoolName is mandatory) .setTargetName("target_function") // set target function's name (optional) (either TargetName or TargetId is mandatory) // .setTargetId(1234567890L) // set the target function's Id (optional) (either TargetName or TargetId is mandatory) .setParams(new JSONObject() { { put("arg1", "job"); put("arg2", "test"); } }) // set params to be passed to target function (optional) .setJobName("job_name") // set job name .build(); // build job meta // generate cron details ZCCronDetails expressionCronDetails = ZCCronBuilder.zcExpressionCronBuilder() // get expression corn builder .setCronStatus(true) // set cron as enabled .setCronExpression("0 0 * 1 1") // set the UNIX cron expression // .setTimezone("America/Los_Angeles") // set the timezone (optional) .setCronName("expression_cron") // set cron name .setCronDescription("expression_cron") // set corn description (optional) .setJobMeta(jobMeta) // set job meta .build(); // build cron details // create expression cron ZCCronDetails expressionCron = jobScheduling.cron.createCron(expressionCronDetails);
Note: We urge you to use this SDK to configure only Dynamic Crons. Use the UI Builder to configure Pre-defined Crons.

Last Updated 2025-06-20 16:21:48 +0530 +0530