I made spring batch job but I stuck at somewhere. I'm trying to take argument from user in spring batch XML job, based on that argument I'll run different steps.
For eg. Argument= new or replace Based on "Argument" , different steps will execute If argument=new then step 1 Else If argument=replace then step 2 Else some error
Any lead or help for your side is highly appreciated.
You can create a decider based on a system property to decide which step to use, something like:
class MyDecider implements JobExecutionDecider {
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
String operation = System.getProperty("operation");
if (operation.equalsIgnoreCase("create"))
return new FlowExecutionStatus("create");
else {
return new FlowExecutionStatus("update");
}
}
}
Then use this decider in your job definition:
<beans:bean id="decider" class="MyDecider"/>
<job id="job">
<step id="step1" next="decision" />
<decision id="decision" decider="decider">
<next on="create" to="createStep" />
<next on="update" to="updateStep" />
</decision>
<step id="createStep"/>
<step id="updateStep"/>
</job>
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.