0

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?

passing year via UI

  • Just to clarify, I want to be able to re-run the job with a different year. So if I have already run 2010, I could start with a different set of job parameters where year=2011. – Kristjan Veskimäe Aug 14 '20 at 22:15

1 Answers1

2

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.

Ilayaperumal Gopinathan
  • 4,099
  • 1
  • 13
  • 12