Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置中心配置的线程池无法初始化到Spring中 #519

Open
hgaong opened this issue Jan 17, 2025 · 1 comment
Open

配置中心配置的线程池无法初始化到Spring中 #519

hgaong opened this issue Jan 17, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@hgaong
Copy link

hgaong commented Jan 17, 2025

首先感谢您使用 DynamicTp,如果使用过程中有任何问题,请按照下述模板反馈问题,请使用 Markdown 语法

版本信息

  • Jdk版本:21
  • SpringBoot版本:3.2.7
  • DynamicTp版本:1.1.9.1-3.x
  • 配置中心类型:nacos
  • 配置中心版本:0.3.0-RC

问题描述

nacos配置了线程池,springboot项目中没有使用任何@bean来创建dtpExecutor1 ,启动时配置文件刷新失败。如果通过@resource尝试注入该线程池会注入失败。
Image

  • 配置文件:
  • 引入的依赖:
<dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>nacos-config-spring-boot-starter</artifactId>
            <version>0.3.0-RC</version>
        </dependency>
        <!--nacos配置中心-->
        <dependency>
            <groupId>org.dromara.dynamictp</groupId>
            <artifactId>dynamic-tp-spring-boot-starter-nacos</artifactId>
            <version>1.1.9.1-3.x</version>
        </dependency>
        <!--兼容sw解决内存泄漏-->
        <dependency>
            <groupId>org.dromara.dynamictp</groupId>
            <artifactId>dynamic-tp-extension-agent</artifactId>
            <version>1.1.9.1-3.x</version>
        </dependency>
        <!--传递sw上下文-->
        <dependency>
            <groupId>org.dromara.dynamictp</groupId>
            <artifactId>dynamic-tp-extension-skywalking</artifactId>
            <version>1.1.9.1-3.x</version>
        </dependency>
  • 代码使用步骤:
  • 报错信息:
  • 猜测可能原因:
    大概原因是:如果只在配置中心配置了线程池但代码中却没有@bean声明对应的线程池,则无法触发代码DtpRegistry.registerExecutor ,以至于refresh时 Map EXECUTOR_REGISTRY中找不到对应的所以跳过刷新。所以官方文档写的如果在nacos中配置了线程池则不要再@bean重复定义线程池是否可信呢?

复现步骤

  1. xxx
  2. xxx

其他信息

  1. xxx
  2. xxx
@hgaong hgaong added the bug Something isn't working label Jan 17, 2025
@KamToHung
Copy link
Collaborator

org.dromara.dynamictp dynamic-tp-spring-cloud-starter-nacos 1.1.9.1-3.x

使用spring-cloud-nacos看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants