How to write file with dynamic number of files in spring batch?

Viewed 25

I'm new in spring batch and very need your help.

How can I writing file in spring batch, which can be write dynamically number of files. How data looks like, in attachmentdata:

So, in here I need to generate files, which classify based on "DayNo", and the "DayNo" is dynamic.

I can't input dynamically the stream in bellow configuration of step:

return stepBuilderFactory.get("step") .<Subscriber, Subscriber>chunk(50) .reader(reader) .processor(processor) .writer(classifierCompositeItemWriter) .stream(singleWriter) // need to pass all the writer here .build();

In my case I don't know how much I need to create the Bean of ItemWriter, if i'm not passing the writer in stream , i'll got "org.springframework.batch.item.WriterNotOpenException: Writer must be open before it can be written to"

What is the better way to solve this ?

0 Answers
Related