官方url 参考最多
传递参数
- 在tester中设置属性
- 在xml中声明属性
- 在batchlet或者listener中利用属性
Properties props = new Properties();
props.setProperty("taskId", String.valueOf(taskId));
int executionId = (int)jobOperator.start("newJobFileTemplate", props);
//jobOperator.stop(executionId);
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
<job version="1.0" restartable="false" id="batch1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/jobXML_1_0.xsd" xmlns="http://xmlns.jcp.org/xml/ns/javaee" >
<properties>
<property name="taskId" value="#{jobParameters['taskId']}"/>
</properties>
String taskId = jobCtx.getProperties().getProperty("taskId");
停止
long executionId = jobOperator.start("newJobFileTemplate", props);
jobOperator.stop(executionId);
在调用stop后,状态是stopped,直接退出,不走step和job的listener
暂时未发现与abandon的区别,除了状态
return的作用
在batchlet的override的process方法最后,默认大家都是返回 return "COMPLETED";
在xml中如果不设置的话,其实返回什么都一样。
但是就像官方文档中给出的例子,譬如<end>,那么根据return的string不同,step会继续或者是停止
譬如 在step5中,如果返回1111,则不会执行下一步,batch结束
<step allow-start-if-complete="false" next="_step6" id="_step5">
<listeners>
<listener ref="stepBatchListener"/>
</listeners>
<batchlet ref="batchlet_step5"/>
<end on="1111" />
</step>
<step allow-start-if-complete="false" next="_step7" id="_step6" >
<listeners>
<listener ref="stepBatchListener"/>
</listeners>
<batchlet ref="batchlet_step6"/>
</step>