Workflow scheduling
This topic describes how to orchestrate jobs using a visual workflow. You can trigger the workflow using cron expressions or API calls.
Usage notes
-
Jobs in a workflow do not have independent schedules. They are triggered by the workflow's schedule.
-
A workflow must contain at least two jobs with dependencies. To schedule a single job, use Task Management.
-
Workflows support the cross-application orchestration of jobs from different applications.
Limitations
Currently, only Java jobs support data transfer. For distributed Java jobs, use the MapReduce model to transfer data.
Next steps
For detailed instructions, see workflow management.
Data transfer between jobs
SchedulerX provides workflow job orchestration and supports data transfer between upstream and downstream jobs.
Return an execution result
/**
*
* @param status
* @param result The data payload. The size must be less than 1,000 bytes.
* @throws Exception
*/
public ProcessResult(boolean status, String result) throws Exception;
At the end of your processor, call this method to return a result.
The result is limited to a size of 1,000 bytes. This is a byte limit, not a character limit. If the result includes multi-byte characters, such as Chinese characters, its byte size may exceed the limit and cause the job to fail.
Get upstream data
List<JobInstanceData> upstreamDatas = context.getUpstreamData();
In a processor, call the getUpstreamData method on the context object to retrieve data from upstream jobs. The data is returned as a list because a job can have multiple parent nodes. Each JobInstanceData object in the list has two properties: JobName (String) and Data (String).
Example
-
First, create three JobProcessors.
public class TestSimpleJobA extends JavaProcessor { @Override public ProcessResult process(JobContext context) throws Exception { System.out.println("TestSimpleJobA " + DateTime.now().toString("yyyy-MM-dd HH:mm:ss")); return new ProcessResult(true, String.valueOf(1)); } }public class TestSimpleJobB extends JavaProcessor { @Override public ProcessResult process(JobContext context) throws Exception { System.out.println("TestSimpleJobB " + DateTime.now().toString("yyyy-MM-dd HH:mm:ss")); return new ProcessResult(true, String.valueOf(2)); } }public class TestSimpleJobC extends JavaProcessor { @Override public ProcessResult process(JobContext context) throws Exception { List<JobInstanceData> upstreamDatas = context.getUpstreamData(); int sum = 0; for (JobInstanceData jobInstanceData : upstreamDatas) { System.out.println("jobName=" + jobInstanceData.getJobName() + ", data=" + jobInstanceData.getData()); sum += Integer.valueOf(jobInstanceData.getData()); } System.out.println("TestSimpleJobC sum=" + sum); return new ProcessResult(true, String.valueOf(sum)); } } -
In the console, configure jobs named JobA, JobB, and JobC. Then, create a workflow as shown in the following figure:

-
After you trigger the workflow, in the left-side navigation pane, click Execution List > Process Instance List. Find the workflow execution record and click Details in the Actions column. Right-click the JobA job and select Details. The Task Instance Details page opens, showing that the result for the JobA instance is 1.
Similarly, the result for the JobB instance is 2, and the result for the JobC instance is 3.
-
Check the console output on the machine where JobC ran.
jobName=jobB, data=2 jobName=jobA, data=1 TestSimpleJobC sum=3