Bạn có chắc chắn muốn xóa bài viết này không ?
Bạn có chắc chắn muốn xóa bình luận này không ?
Spring Batch – Programmatic Flow Decision
https://grokonez.com/spring-framework/spring-batch/spring-batch-programmatic-flow-decision
Spring Batch – Programmatic Flow Decision
In the article, JavaSampleApproach will introduce about Programmatic Flow Decisions in Spring Batch.
Related Post: Spring Batch
A. Concept
Spring Batch provides mechanics for controlling the flow steps of batch job: JobExecutionDecider interface & decision tag
1. JobExecutionDecider
The interface allowing for programmatic access to the decision on what the status of a flow should be.
In here we need overwrite the function: FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution): Strategy for branching an execution based on the state of an ongoing. The return value will be used as a status to determine the next step in the job.
package org.springframework.batch.core.job.flow;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
/**
* Interface allowing for programmatic access to the decision on what the status
* of a flow should be. For example, if some condition that's stored in the
* database indicates that the job should stop for a manual check, a decider
* implementation could check that value to determine the status of the flow.
*
* @author Dave Syer
* @since 2.0
*/
public interface JobExecutionDecider {
/**
* Strategy for branching an execution based on the state of an ongoing
* {@link JobExecution}. The return value will be used as a status to
* determine the next step in the job.
*
* @param jobExecution a job execution
* @param stepExecution the latest step execution (may be null)
* @return the exit status code
*/
FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution);
}
2. "decision" tag
"decision" tag specify the decider to use as well as all of the transitions
Example:
More at:
https://grokonez.com/spring-framework/spring-batch/spring-batch-programmatic-flow-decision
Spring Batch – Programmatic Flow Decision




