我使用Spring管理为我们的系统运行批处理作业。我们得把这些工作做很多次。我正在使用spring批管理的rest接口。我使用开始了一项新工作。
RestTemplate tpl = new RestTemplate();
tpl.postForLocation(Constants.SPRING_BATCH_ADMIN_URL + "/jobs/myBatchJob;这可以启动第一个作业,但在随后的作业中,请求不会启动作业的新实例。在作业配置文件中,我定义了一个jobParmatersIncrementer
<job id="myBatchJob" xmlns="http://www.springframework.org/schema/batch"
restartable="true" incrementer="jobParametersIncrementer">
<bean id="jobParametersIncrementer"
class="org.springframework.batch.core.launch.support.RunIdIncrementer" />我尝试过将我的postForLocation更改为
List<JobInstance> jobInstances = jobExplorer.getJobInstances("myBatchJob", 0, 30);
JobParameters jobParameters = jobInstances.get(0).getJobParameters();
RunIdIncrementer runIdIncrementer = new RunIdIncrementer();
JobParameters jobParameters = runIdIncrementer.getNext(jobParameters);
RestTemplate tpl = new RestTemplate();
tpl.postForLocation(Constants.SPRING_BATCH_ADMIN_URL +
"/jobs/myBatchJob?launch=Launch&{parameters}",
"runid",
jobParameters.toString());它通过单击“启动”按钮从spring批处理管理页面运行。这在参数编辑框中。
run.id(long)=1如何在Spring中多次从另一个web应用程序运行作业?
发布于 2014-10-08 10:12:30
您可以在请求体中传递一个参数jobParameter,该参数包含您的元组。
jobParameters=run.id(long)=123并将其附加到post请求的url编码。这是我的jquery解决方案。
$.post('<url>/jobs/myBatchJob', 'jobParameters=' + encodeURIComponent('run.id(long)=123')).done(function() {
// do something
});https://stackoverflow.com/questions/16180108
复制相似问题