0

I have a CSV file that contains records of data (cases), for which I created a caseDTO object , however some of the properties of the caseDTO must be field from data included in the file name (every file must has a name with strict structure that contains some data).

What i want to achieve is to pass the data included in the file name to the item processor where i will append this data into every caseDTO before passing it to the item writer.

Does any one knows how to pass data to a step itemProcessor when I launch the job from the controller?

Thanks in advance.

Mario Codes
  • 689
  • 8
  • 15
  • 1
    have you tried to pass filename as job parameters https://stackoverflow.com/questions/21557623/how-do-i-set-jobparameters-in-spring-batch-with-spring-boot? – Andriy Budzinskyy Sep 15 '20 at 11:16

1 Answers1

0

the simplest solution is to set the dynamic parameters in the job parameters so the step's writer , processor , reader can have access to it . by injecting their values as following

@Value("#{jobParameters['fileName']}") public void setFileName(final String name) { //... }