1 回答

TA貢獻1772條經(jīng)驗 獲得超6個贊
讓我們看一下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對象,但這實際上與您的工作是否完成無關(guān)。為了實現(xiàn)這個目標,我相信我們需要像JobExecutionListenerhook 這樣的東西。
有一個示例step:
@MessagingGateway(name = "notificationExecutionsListener", defaultRequestChannel = "stepExecutionsChannel")
public interface NotificationExecutionListener extends StepExecutionListener {}
但同樣的方法也適用于JobExecutionListener.
因此,您需要將流程分成兩部分,并.gateway(acknowledgementFlow)僅從afterJob(JobExecution jobExecution)您的工作中執(zhí)行的任務(wù)中進行調(diào)用。
添加回答
舉報