简体   繁体   English

如何使用 1 Spring 批处理作业来处理多个请求

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

I am using Spring Batch job to run multiple jobs.我正在使用 Spring 批处理作业来运行多个作业。 All the jobs use a ItemReader and FlatFileItemWriter which reads some data and generate a text file.所有作业都使用 ItemReader 和 FlatFileItemWriter 读取一些数据并生成文本文件。 I have created One single batch job with its own Reader and Writer for each of the file that has to be created.我为每个必须创建的文件创建了一个具有自己的 Reader 和 Writer 的批处理作业。 For example if I am creating 10 different files, I have 10 jobs, I have 10 Readers and 10 writers.例如,如果我要创建 10 个不同的文件,我有 10 个工作,我有 10 个读者和 10 个作者。 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.具有自己的 DTO 的文件。

public class ClassWriter1 extends FlatFileItemWriter<DTO1>{
}

public class ClassWriter2 extends FlatFileItemWriter<DTO2>{
}

etc... 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.您可以将创建文件的方法视为异步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何创建主作业来处理多个春季批作业? - How to create Master Job to process multiple spring batch job? 如何在OSGI中使用Spring Batch - How can I use Spring Batch with OSGI 如何使用不同的作业参数多次运行spring batch作业? - How to run spring batch job multiple times with different job parameters? 如何更改 di job CRON 表达式以便每周运行两次 Spring Batch 作业? - How can I change di job CRON expression in order to run my Spring Batch job twice a week? 如何使用 Spring Batch 处理多行? - How to process multiple lines with the Spring Batch? 如何使用 spring 构建器在 spring 批处理中配置作业和步骤 inheritance? - How can I configure job and step inheritance in spring batch using spring builders? Spring Batch多个作业执行 - Spring Batch Multiple Job execution 如何从Spring批处理器process()方法向Spring批处理作业启动方法抛出异常? - How to throw exception from spring batch processor process() method to Spring batch job started method? 我们可以创建同一个java(spring)批处理作业的多个实例吗? - Can we create multiple instances of a same java(spring) batch job? 如何在Spring Batch中动态定义多个作业? - How can I define multiple jobs dynamically in Spring Batch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM