我正在使用Spring Batch 3.0版本的布局。
创建一个Job并通过执行TASKLET的JobLauncher run方法来执行放置。
我想更准确地了解作业是否通过TASKLET中的查询中的插入逻辑以及相应的JobId和除元表以外的其他表执行。
bulkWrite()
用于调用tasklet的代码-
public class SampleScheduler {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private JobLauncher jobLauncher;
@Autowired
private Job sampleJob;
public void run() {
try {
String dateParam = new Date().toString();
JobParameters param = new JobParametersBuilder().addString("date",dateParam).toJobParameters();
JobExecution execution = jobLauncher.run(sampleJob, param);
log.debug("###################################################################");
log.debug("Exit Status : " + execution.getStatus());
log.debug("###################################################################");
} catch (Exception e) {
// e.printStackTrace();
log.error(e.toString());
}
}
}
这是我的tasklet代码。
public class SampleTasklet implements Tasklet{
@Autowired
private SampleService sampleService;
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
sampleService.query();
return RepeatStatus.FINISHED;
}
}
在上面的任务代码中尝试这样做是否正确?