【发布时间】:2021-05-07 19:20:00
【问题描述】:
我有一个场景,我需要大约 50-60 个不同的进程同时运行并执行一个任务。
每个进程都必须使用 sql 查询从数据库中获取数据,方法是传递一个值并获取要在后续任务中运行的数据。 select col_1, col_2, col_3 from table_1 where col_1 = :Process_1;
@Bean
public Job partitioningJob() throws Exception {
return jobBuilderFactory.get("parallelJob")
.incrementer(new RunIdIncrementer())
.flow(masterStep())
.end()
.build();
}
@Bean
public Step masterStep() throws Exception {
//How to fetch data from configuration and pass all values in partitioner one by one.
// Can we give the name for every process so that it is helpful in logs and monitoring.
return stepBuilderFactory.get("masterStep")
.partitioner(slaveStep())
.partitioner("partition", partitioner())
.gridSize(10)
.taskExecutor(new SimpleAsyncTaskExecutor())
.build();
}
@Bean
public Partitioner partitioner() throws Exception {
//Hit DB with sql query and fetch the data.
}
@Bean
public Step slaveStep() throws Exception {
return stepBuilderFactory.get("slaveStep")
.<Map<String, String>, Map<String, String>>chunk(1)
.processTask()
.build();
}
由于我们在 Apache Camel 中有 Aggregator 和 parallelProcessing,Spring Batch 是否有任何类似的功能可以完成相同的工作?
我是 Spring Batch 的新手,目前正在探索它是否可以处理卷。 因为这将是一个 24*7 运行的负载繁重的应用程序,并且每个进程都需要同时运行,其中每个线程应该能够支持进程内的多个线程。
有没有办法监控这些进程,让它无论如何都会被终止,我应该能够重新启动那个特定的进程? 请帮忙解决这个问题。
【问题讨论】:
标签: spring-batch spring-batch-tasklet spring-batch-job-monitoring spring-batch-stream