All Products
Search
Document Center

SchedulerX:JobContext parameters

Last Updated:Mar 11, 2026

The JobContext object provides runtime information about the current job execution, including identifiers, scheduling times, retry state, sharding details, and upstream workflow data.

Basic usage

Access JobContext parameters through getter methods in your job handler:

public class SampleJobProcessor extends JavaProcessor {
    @Override
    public ProcessResult process(JobContext context) throws Exception {
        // Job and instance identifiers
        long jobId = context.getJobId();
        long instanceId = context.getJobInstanceId();

        // Scheduling metadata
        DateTime scheduledTime = context.getScheduleTime();
        DateTime dataTime = context.getDataTime();

        // Static parameters configured in the SchedulerX console
        String params = context.getJobParameters();

        // Dynamic parameters passed through API calls
        String dynamicParams = context.getInstanceParameters();

        // Retry state
        int currentAttempt = context.getAttempt();
        int maxRetries = context.getMaxAttempt();

        System.out.println("Job " + jobId + ", instance " + instanceId
            + ", attempt " + currentAttempt + "/" + maxRetries);

        return new ProcessResult(true);
    }
}

Job and instance identifiers

ParameterTypeDescription
jobIdlongJob ID.
jobInstanceIdlongJob instance ID.
jobTypeStringJob type.
taskIdlongTask ID within a distributed job. The root task ID is 0.
taskNameStringTask name.
taskObjectTask body.

Scheduling times

ParameterTypeDescription
scheduleTimeDateTimeScheduled time of the instance.
dataTimeDateTimeTime when the job is run on the instance.

Job parameters

ParameterTypeDescription
jobParametersStringStatic parameters configured in the SchedulerX console. Maximum size: 10,000 bytes.
instanceParametersStringDynamic parameters passed when an instance is triggered through an API call.

Retry parameters

ParameterTypeDescription
maxAttemptintMaximum number of retries for the job instance.
attemptintCurrent retry count for the job instance.
taskMaxAttemptintMaximum number of retries for the task.
taskAttemptintCurrent retry count for the task.

Sharding parameters

Available only when Execution mode is set to Broadcast run or Shard run.

ParameterTypeDescription
shardingIdLongShard ID. Available in Broadcast run and Shard run modes.
shardingParameterStringSharding parameter. Available only in Shard run mode.
shardingNumintTotal number of shards. Available in Broadcast run and Shard run modes.

Example:

public class ShardJobProcessor extends JavaProcessor {
    @Override
    public ProcessResult process(JobContext context) throws Exception {
        Long shardId = context.getShardingId();
        int totalShards = context.getShardingNum();
        String shardParam = context.getShardingParameter();

        System.out.println("Processing shard " + shardId + " of " + totalShards);

        return new ProcessResult(true);
    }
}

Workflow parameters

Available when the job runs as part of a workflow.

ParameterTypeDescription
workflowIdLongWorkflow ID.
wfInstanceIdlongWorkflow instance ID.
upstreamDataList<JobInstanceData>Data from upstream job instances in the workflow. A workflow may have multiple upstream instances, so this parameter returns a list.