简体   繁体   English

taskScheduler池的奇怪行为

[英]Strange behavior with taskScheduler pool

I have two spring boot app (1.4.3.RELEASE) which are on the same server. 我有两个弹簧启动应用程序(1.4.3.RELEASE),它们位于同一台服务器上。 The app A is a monolithic app which contains a part of code used to process alerts and the app B is a new dedicated app which only process alerts. 应用程序A是一个单一的应用程序,其中包含用于处理警报的部分代码,而应用程序B是一个仅处理警报的新专用应用程序。 The goal here is to break the monolotic app in small apps. 这里的目标是打破小应用程序中的monolotic应用程序。 For now, the two codes run together because I have old systems which always call the app A. 现在,这两个代码一起运行,因为我有旧系统,总是调用应用程序A.

The two app have a taskScheduler configured based on a ThreadPoolTaskScheduler. 这两个应用程序有一个基于ThreadPoolTask​​Scheduler配置的taskScheduler。

@Configuration
public class TaskSchedulerConfig {

    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
        threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true);
        threadPoolTaskScheduler.setPoolSize(100);

        return threadPoolTaskScheduler;
    }
}

Yesterday, I have experienced a strange behavior : 昨天,我经历了一个奇怪的行为:

  1. An alert has been detected and sent to the new app B -> OK 检测到警报并将其发送到新应用程序B - >确定
  2. The app B received the alert and start to process it based on the taskScheduler -> OK 应用程序B收到警报并开始根据taskScheduler处理它 - >确定
  3. The first step has been processed by the app B -> OK 第一步已由应用程序B处理 - >确定
  4. The second step has been processed by the app A -> NOK, strange behavior 第二步已经被app A - > NOK处理,这是一种奇怪的行为
  5. The third step has been processed by the app B as expected -> OK 第三步已由应用程序B按预期处理 - >确定

How can this be possible? 这怎么可能? For me, each taskScheduler is attached to the app which created it. 对我来说,每个taskScheduler都附加到创建它的应用程序。 Where am I wrong? 我哪里错了?

UPDATE UPDATE

I have a real box which emit alerts. 我有一个发出警报的真实盒子。 Those alerts must be processed by a new application. 这些警报必须由新应用程序处理。 But I have also old box which have not migrate to the new system. 但我还有旧盒子没有迁移到新系统。 So I have the processing code in two different projects. 所以我在两个不同的项目中有处理代码。

I have a new box with the new code which have created an alert on the new system. 我有一个新代码的新框,它在新系统上创建了一个警报。 This alert generate a state machine which is processed in async with a task scheduler. 此警报生成一个状态机,该状态机与任务调度程序异步处理。 After alert creation, the new app starts to process the state machine and at the middle of the processing the old application wake up and process a step of the alert. 创建警报后,新应用程序开始处理状态机,并在处理过程中唤醒旧应用程序并处理警报步骤。 After that, the new application wake up again and normally close the alert. 之后,新应用程序再次唤醒并正常关闭警报。

The problem is : why the old application wake up to process an alert? 问题是:为什么旧应用程序会唤醒以处理警报? Is there a known issue with a threadPoolTaskScheduler? threadPoolTask​​Scheduler是否存在已知问题?

There is no way that two different applications have this behavior since they are running in isolated processes. 由于它们在隔离的进程中运行,因此两种不同的应用程序无法实现此行为。 Threads (of the same process) run in a shared memory space, while processes run in separate memory spaces, so there is no 'bridge' between them. 线程(相同进程)在共享内存空间中运行,而进程在不同的内存空间中运行,因此它们之间没有“桥接”。

If they share the same database, they might be listening to the same events, but only if you have that logic implemented by you. 如果它们共享同一个数据库,则它们可能正在侦听相同的事件,但前提是您已实现该逻辑。

If I had to guess, given that both are webapps I'd say that there might be some HTTP call somewhere in the code, still aiming to an old endpoint, or some other trigger (crons?) inside the server that is kickstarting the old app. 如果我不得不猜测,鉴于两者都是webapps,我会说在代码中的某个地方可能会有一些HTTP调用,仍然针对一个旧的端点,或者服务器内的一些其他触发器(crons?)启动旧的应用程序。

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

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