gpt4 book ai didi

Java EE JSR 352 - Jberet 动态作业生成器和执行

转载 作者:行者123 更新时间:2023-12-02 12:50:00 24 4
gpt4 key购买 nike

从 Jberet 了解 userguide可以动态构建作业来替代静态 xml,但该指南没有任何关于如何执行作业构建的输入,因此愿意知道如何执行作业。

Job job = new JobBuilder(jobName)
.restartable(false)
.property("jobk1", "J")
.property("jobk2", "J")
.listener("jobListener1", new String[]{"jobListenerk1", "#{jobParameters['jobListenerPropVal']}"},
new String[]{"jobListenerk2", "#{jobParameters['jobListenerPropVal']}"})

.step(new StepBuilder(stepName)
.properties(new String[]{"stepk1", "S"}, new String[]{"stepk2", "S"})
.batchlet(batchlet1Name, new String[]{"batchletk1", "B"}, new String[]{"batchletk2", "B"})
.listener("stepListener1", stepListenerProps)
.stopOn("STOP").restartFrom(stepName).exitStatus()
.endOn("END").exitStatus("new status for end")
.failOn("FAIL").exitStatus()
.nextOn("*").to(step2Name)
.build())

.step(new StepBuilder(step2Name)
.batchlet(batchlet1Name)
.build())

.build();

最佳答案

简而言之,您可以使用以下方法来启动使用 Java JSL 创建的作业:

org.jberet.operations.AbstractJobOperator#start(org.jberet.job.model.Job, java.util.Properties)

1.3.0测试版

由于Java JSL是一项额外功能,因此您需要获取JobOperator的JBeret实现并调用上面的start方法:

import org.jberet.job.model.Job;
import org.jberet.operations.JobOperatorImpl;
import org.jberet.spi.JobOperatorContext;

JobOperatorImpl jobOperator = (JobOperatorImpl) JobOperatorContext.getJobOperatorContext().getJobOperator();

Job job = new JobBuilder(jobName)
.step(new StepBuilder(stepName)
.reader(...)
.writer(...)
.build())
.build();
Properties params = null;
long jobExecutionId = jobOperator.start(job, params);

版本 1.2.0-最终版

JobOperatorImpl jobOperator = (JobOperatorImpl) BatchRuntime.getJobOperator();
Properties jobProperties = new Properties();
long jobExecutionId = jobOperator.start(job, jobProperties);

有关更多详细信息,请参阅 JBeret sample app javaJSL ,以及代码how to get JBeret job operator .

关于Java EE JSR 352 - Jberet 动态作业生成器和执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44629356/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com