Set data time
更新时间:
复制 MD 格式
In SchedulerX, data time lets you process data from a time period separate from the job's execution time.
Procedure
For example, a job can run at 00:30 every day but process data from the previous day. To do this, you can set a time offset to make the data time one hour earlier than the job's execution time.
- Integrate the SchedulerX agent into your application and add code to retrieve the data time. For more information, see the quick start guide.
public class TestHelloJob extends JavaProcessor { @Override public ProcessResult process(JobContext context) throws Exception { System.out.println("hello schedulerx2.0"); System.out.println("dataTime=" + context.getDataTime().toString("yyyy-MM-dd HH:mm:ss")); return new ProcessResult(true); } } - In the console, create a job. For more information, see Create a job. In the Schedule Configuration section, set the time offset to -3600 (in seconds). This creates a backward offset of 3,600 seconds (one hour). The job's execution time does not change. When the job runs,
context.getDataTime()returns a data time of 23:30 on the previous day.For the time type, select cron. For the cron expression, enter0 30 0 */1 * ?. This schedules the job to run at 00:30 every day.
Verify the result
- After creating the job, go to the Execution List page. Find the job instance, and in the Actions column, click Details.
- On the Job Instance Details page, click Basic Information.
- On the Basic Information tab, verify that the Data Time is correct.
该文章对您有帮助吗?