gpt4 book ai didi

java - Spring 批处理 : Execution order for multiple JobExecutionListener instances for a single job

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

给定一个 Spring Batch 作业,该作业配置了一系列 JobExecutionListener 实例,每个监听器的执行顺序是什么。示例:

<job id="myJob" xmlns="http://www.springframework.org/schema/batch">

<batch:listeners>
<batch:listener ref="myJobExecutionListener1" />
<batch:listener ref="myJobExecutionListener2" />
<batch:listener ref="myJobExecutionListener3" />
<batch:listener ref="myJobExecutionListener4" />
</batch:listeners>

<!-- job config continues -->
</job>

在上面的例子中,保证监听器是按照配置的顺序执行还是按照随机的顺序执行。我尝试查看 Spring Batch 引用文档,但就我的研究而言,我找不到此文档。

最佳答案

监听器将按照其声明顺序执行。在您的示例中,将按以下顺序调用它们:

myJobExecutionListener1.beforeJob
myJobExecutionListener2.beforeJob
myJobExecutionListener3.beforeJob
myJobExecutionListener4.beforeJob

// .. job output

myJobExecutionListener4.afterJob
myJobExecutionListener3.afterJob
myJobExecutionListener2.afterJob
myJobExecutionListener1.afterJob

关于java - Spring 批处理 : Execution order for multiple JobExecutionListener instances for a single job,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58619936/

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