1 回答
TA贡献1772条经验 获得超5个赞
让我们看一下JobLauncher.run()JavaDocs!
* Start a job execution for the given {@link Job} and {@link JobParameters}
* . If a {@link JobExecution} was able to be created successfully, it will
* always be returned by this method, regardless of whether or not the
* execution was successful. If there is a past {@link JobExecution} which
* has paused, the same {@link JobExecution} is returned instead of a new
* one created. A exception will only be thrown if there is a failure to
* start the job. If the job encounters some error while processing, the
* JobExecution will be returned, and the status will need to be inspected.
因此,如果工作已成功开始,您将获得一个JobExecution对象,但这实际上与您的工作是否完成无关。为了实现这个目标,我相信我们需要像JobExecutionListenerhook 这样的东西。
有一个示例step:
@MessagingGateway(name = "notificationExecutionsListener", defaultRequestChannel = "stepExecutionsChannel")
public interface NotificationExecutionListener extends StepExecutionListener {}
但同样的方法也适用于JobExecutionListener.
因此,您需要将流程分成两部分,并.gateway(acknowledgementFlow)仅从afterJob(JobExecution jobExecution)您的工作中执行的任务中进行调用。
添加回答
举报