简体   繁体   中英

Spring batch how to fail a step and therefor the job from inside a Partitioner

I currently have a partitioner extending partitiner and Overriding the method partition.

In the partition method I try to read configuration records from the database in order to partition downloads

If I'm unable to read from the database for some reason I want to fail the Job.

How do I do exactly that?

You can use SimpleJobOperator bean for this purpose.

SimpleJobOperator bean has method jobOperator.stop(executionId) method which takes executionId of job as parameter.

You can get executionId from JobExecution . something like this executionId =JobExecution.getId();

I am using similar setup and it's working fine. Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM