简体   繁体   中英

how can I use 1 Spring Batch job to process multiple requests

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM