java - Spring 批处理 : Use of ExcecutionContext to pass step attributes

标签 java spring spring-batch spring-batch-admin spring-framework-beans

我有一些 Spring 批处理作业,其步骤数较多,运行时间不定。我现在需要为每个步骤定义阈值,以检查其运行是否超过阈值时间。

我正在考虑以某种方式将此值传递给 StepExecution 类的 ExcecutionContext。

我已经浏览过https://docs.spring.io/spring-batch/trunk/reference/html/configureJob.html和其他文档来了解值如何传递 ExcecutionContext,但找不到任何内容。

任何人都可以帮助我了解 StepExecution 的 ExcecutionContext 是如何初始化的,以及我可以在每个步骤定义中传递一些自定义参数吗?

最佳答案

我们的项目中也有类似的情况,我们确实通过 jobParameters 步骤传递值,并像这样修改或添加作业参数中的值

chunkContext.getStepContext().getStepExecution().getJobParameters().getParameters().put("THRESHOLD", "VALUE")

在 StepListener 中,我们检查或检索了该值并进行了相应的处理。

关于java - Spring 批处理 : Use of ExcecutionContext to pass step attributes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48153551/

相关文章:

java - 如何在集合(数组,集合等)中获取hadoop reducer结果?

java - 获取 java.lang.ClassCastException : javax. xml.bind.JAXBElement cannot be cast to com.[mySchema] 在实现 ItemProcessor 时

java - InternalResourceViewResolver 未解析

java - Hibernate 在 Spring 事务中抛出 TransactionRequiredException

spring-batch - Spring Batch CompositeItemWriter 如何为委托(delegate)编写者管理事务?

java - 如何在 JFreeChart 中用鼠标滚轮旋转饼图?

Java,Glassfish JPA : NoClassDefFoundError: javax/persistence/spi/PersistenceUnitInfo (JDK6/7 only)

Spring 批量测试用例

java - Hibernate和图形设计,该走哪条路?

java - Spring 批处理 :Aggregated reader/writer Issue