简体   繁体   English

停止在春季批处理中运行的线程

[英]Stop a thread running in spring batch

I have a Spring batch application, that uses partition to run some threads.我有一个 Spring 批处理应用程序,它使用分区来运行一些线程。 the problem is, I need to stop my thread if it reaches a certain time.问题是,如果线程到达特定时间,我需要停止线程。

I don't know how to do that.我不知道该怎么做。 I have a partitioner step我有一个分区步骤

@Bean
public Step partitionerStep() {
    return stepBuilderFactory.get("PARTITIONER_STEP")
            .partitioner("SLAVE_STEP", partitioner())
            .step(stepConcederPerfilNormal())
            .taskExecutor(taskExecutor())
            .build();
}

First I thought I could stop my thread using ThreadPoolTaskExecutor but isn't work as I thought首先,我认为我可以使用 ThreadPoolTask​​Executor 停止我的线程,但并没有像我想象的那样工作

@Bean
public TaskExecutor taskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setMaxPoolSize(200);
    executor.setCorePoolSize(50);
    executor.setAllowCoreThreadTimeOut(true);
    return executor;
}

Just to fix it.只是为了修复它。 I need to stop my thread if it's running for 1H30M如果我的线程正在运行 1H30M,我需要停止它

Spring Batch does not create or manage threads, it delegates that to a TaskExecutor . Spring Batch 不创建或管理线程,它将线程委托给TaskExecutor

I need to stop my thread if it's running for 1H30M如果我的线程正在运行 1H30M,我需要停止它

The following might help: Stop the thread after a particular time以下可能有帮助: 在特定时间后停止线程

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

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