There is Data Flow deployed in Docker and a Spring Batch application is deployed as a 'Task' and turned into a task.
I am trying to provide a year job parameter for my task. I have tried using a properties class with @ConfigurationProperties
annotation like in timestamp example. Then I turn this into job parameter via JobParametersIncrementer
.
@Bean
public Job job() {
return this.jobBuilderFactory
.get("job")
.incrementer(new SampleIncrementer(year))
.start(step())
.build();
}
class SampleIncrementer implements JobParametersIncrementer {
private final Long year;
public SampleIncrementer(final Long year) {
this.year = year;
}
public JobParameters getNext(final JobParameters parameters) {
if (isNull(parameters)) {
return new JobParametersBuilder().addLong("year", year).toJobParameters();
}
if (isNull(parameters.getLong("year"))) {
return new JobParametersBuilder(parameters).addLong("year", year).toJobParameters();
}
return parameters;
}
}
But the job parameter isn't found later in Step.
Is there a way to pass job parameters from Spring Cloud Data Flow UI to execution?
The job parameters are passed as Arguments
where you don't need to specify the --
prefix. For instance, in this case you need to specify year=2011
as argument in Arguments
section.