简体   繁体   English

如何从UI发送Spring批处理块大小

[英]How to send spring batch chunk size from UI

Can someone help to understand how the chunk size 1 or 10 can be supplied from spring controller to step as a variable. 有人可以帮助您了解如何从spring控制器提供变量大小1或10的块。 Whether this will work with step scope here? 这是否适用于步进范围? or have to write in @beforeStep? 还是必须在@beforeStep中写?

@Bean @豆角,扁豆

public Step step1() {
    return stepBuilderFactory.get("step1")
            .<Person, Person> chunk(**10**)
            .reader(reader(null))
            .processor(processor())
            .writer(writer())
            .build();
}

The way you are trying to do it won't work. 您尝试执行此操作的方式将无效。 In order for a value to be passed in as a job parameter, the object it's being set on needs to be step scoped and a step itself can't be step scoped. 为了将值作为作业参数传递,设置该对象的对象需要逐步限定范围,而步骤本身不能逐步限定范围。 What you could do is create a step scoped CompletionPolicy that uses that to determine if the chunk is complete. 您可以做的是创建一个范围为CompletionPolicy的步骤,使用该步骤来确定块是否完整。 In short, configuring the Spring Batch CountingCompletionPolicy as a step scoped bean and configuring your step with that should allow you to set the max count via a job parameter. 简而言之,将Spring Batch CountingCompletionPolicy配置为步骤范围的Bean,并以此配置步骤,则应允许您通过job参数设置最大计数。

You can read more about the CompletionPolicy and it's related implementations here: http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/repeat/CompletionPolicy.html 您可以在此处阅读有关CompletionPolicy及其相关实现的更多信息: http : //docs.spring.io/spring-batch/apidocs/org/springframework/batch/repeat/CompletionPolicy.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM