Java 为什么spring批处理没有jobinstance上下文在同一jobinstanceid的不同JobExecution之间共享数据?

Java 为什么spring批处理没有jobinstance上下文在同一jobinstanceid的不同JobExecution之间共享数据?,java,spring,spring-batch,Java,Spring,Spring Batch,我有一个spring批处理工作,我们正在执行以下任务 <job> <tasklet1>send msg to external sys1 </task1> <!--After sending message to sys1 stop the job --> <!--listener to read response from sys1 and restart job from taskl

我有一个spring批处理工作,我们正在执行以下任务

<job>

         <tasklet1>send msg to external sys1 </task1>

        <!--After sending message to sys1 stop the job -->

        <!--listener to read response from sys1 and restart job from tasklet2  using jobexecutiondecider -->

        <tasklet2>Process response from sys1</tasklet>

        <tasklet3>send msg to external sys2</task1>

        <!--After sending message to sys2 stop the job -->

        <!--listener to read response from sys2 and restart job from tasklet4  using jobexecutiondecider -->

        <tasklet4>Process response from sys2</tasklet>

</job>

将消息发送到外部sys1
来自sys1的进程响应
将消息发送到外部sys2
来自sys2的进程响应
Spring批处理表将针对相同的作业实例id执行三次作业,因为我们将多次重新启动相同的作业实例id,如下所示

  • Jobex1.1
  • Jobex1.2
  • Jobex1.3
现在我面临一个问题,即在Jobexe1.1的jobexecution上下文中设置的值在Jobexe1.2的上下文中不存在

问题: 1如果我在Jobexe1.1的jobexecution上下文中存储了一些内容, 这对Jobexe1.2的jobexecution上下文可用吗

问题2:如果不是上述情况,那么我们如何在作业实例id为1的不同作业执行之间共享数据

问题3:为什么spring批处理没有类似于jobinstance执行上下文的内容,以便我们可以轻松地在一个作业实例id的不同作业执行之间共享数据


注意-我知道stepexecutioncontext用于在步骤内共享数据,jobexecutioncontext用于在步骤间共享数据以执行作业。

如何将值设置到jobexecutioncontext中?您在作业执行中输入的内容将在下次执行时可用,前提是允许完成(成功或不成功)进行此更改的步骤。因此,您可能在某个地方做错了什么,但您需要提供更多详细信息。@MichaelPralow我正在使用chunk上下文,并从中获取作业ec=xecutiona,并按如下所示进行设置chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put(“值”,“foo”)@Artefactor您想从我这里了解更多信息吗?@DevG在
JobRepository::updateExecutionContext
处设置一个断点,然后确定是否根本没有调用该方法,或者是否正在回滚更新表的事务。