Skip to content

TTL 装饰的线程池无法执行等待任务完成插件 #990

Closed
@pirme

Description

@pirme

创建线程池代码如下:

@Slf4j
@Configuration
public class DynamicThreadPoolConfig {

    @Bean
    @DynamicThreadPool
    public Executor messageConsumeTtlDynamicThreadPool() {
        String threadPoolId = MESSAGE_CONSUME;
        ThreadPoolExecutor customExecutor = ThreadPoolBuilder.builder()
                .dynamicPool()
                .threadFactory(threadPoolId)
                .threadPoolId(threadPoolId)
                .build();
        // Ali ttl adaptation use case.
        Executor ttlExecutor = TtlExecutors.getTtlExecutor(customExecutor);
        return ttlExecutor;
    }
}

该代码只是把 TTL 对应的 TtlExecutors.getTtlExecutor 创建为 SpringBean,内部的动态线程池并没有注册为 SpringBean,导致无法执行等待任务完成插件。

修改建议:

将 TTL 内部持有的动态线程池对象注册为 SpringBean。

Metadata

Metadata

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions