0
votes

I am using Spring Batch job to run multiple jobs. All the jobs use a ItemReader and FlatFileItemWriter which reads some data and generate a text file. I have created One single batch job with its own Reader and Writer for each of the file that has to be created. For example if I am creating 10 different files, I have 10 jobs, I have 10 Readers and 10 writers. Is there a way that I can have only one job and one reader and one writer which can take care of all the requests of creating different files. The files that are have their own DTO.

public class ClassWriter1 extends FlatFileItemWriter<DTO1>{
}

public class ClassWriter2 extends FlatFileItemWriter<DTO2>{
}

etc...

1
Use one job to trigger multiple threads based on number of files that need to be read/write.Em Ae
@Em, I don't want to create all files at the same time. It depends on the request made.user1015388
Have you tried to create a generic abstract job configuration class (like AbstractJobConfig<T>) and multiple concrete ones for each job (like Job1Config extends AbstractJobConfig<DTO1>, Job2Config extends AbstractJobConfig<DTO2>) ?Mahmoud Ben Hassine

1 Answers

0
votes

If you create file based on request, you dont need a batch job. On every request hits the method of creating file. You can treat the method of creating file asynchronous.