orgIds = req.getOrgIds(); // 修复职" /> orgIds = req.getOrgIds(); // 修复职" /> orgIds = req.getOrgIds(); // 修复职"/>

kubernetes pod cause ThreadPoolTaskExecutor's CallerRunsPolicy Not effective

17 views Asked by At
@PostMapping("/fixUseHeadhunter")
public AtsRespEntity fixUseHeadhunter(@RequestBody OrgIdsReqDTO req) {

    List<String> orgIds = req.getOrgIds();
    // 修复职位发布猎头状态
    AsyncUtil.runAllOfConcurrency("fixUseHeadhunter", orgIds.stream()
        .map(orgId -> (Runnable) () -> jobScriptService.fixUseHeadhunter(orgId))
            .collect(Collectors.toList()));
    return AtsRespEntity.success();
}

BeanFactory beanFactory = SpringContextHolder.getApplicationContext();
ThreadPoolTaskExecutor executor = ExecutorBuilder.create()
                .setCorePoolSize(5)
                .setMaxPoolSize(10)
                .setQueueCapacity(5)
                .setHandler(new CallerRunsPolicy())
                .build();

In the above code, thread pool configuration and interface execute tasks through the thread pool. The CallerRunsPolicy handler is used and the task code executed has no exceptions. Now it has been found that the results of executing the locally initiated project are as expected, but the results when deploying it to Kubernetes are not as expected. The main thread of Kubernetes only completed one task, resulting in many tasks remaining to be executed.

I have tried different environments, local environment, testing environment and production environment. The local environment is executed by starting the JVM through Mac Book Pro, while the testing and production environments are executed through the Kubernetes container. Currently, only the results of the local environment meet expectations.

0

There are 0 answers