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

[Feature] How do I enable the virtual thread function in 3.3? #15156

Closed
4 tasks done
JavaLionLi opened this issue Feb 17, 2025 · 4 comments
Closed
4 tasks done

[Feature] How do I enable the virtual thread function in 3.3? #15156

JavaLionLi opened this issue Feb 17, 2025 · 4 comments
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@JavaLionLi
Copy link
Contributor

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Apache Dubbo Component

Java SDK (apache/dubbo)

Descriptions

How do I enable the virtual thread function in 3.3?
Or you can have a document address
I didn't find it in the documentation

Related issues

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@JavaLionLi JavaLionLi added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Feb 17, 2025
@songxiaosheng
Copy link
Member

In Java 19 and 20, try Executors.newVirtualThreadPerTaskExecutor

@Configuration
public class DubboConfig {
    @Bean
    public ExecutorService virtualThreadExecutor() {
        return Executors.newVirtualThreadPerTaskExecutor();
    }
}
dubbo:
  protocol:
    name: dubbo
    port: 20880
    dispatcher: all
    threadpool: cached
    # 关键配置:使用虚拟线程
    executor: virtualThreadExecutor

@JavaLionLi
Copy link
Contributor Author

In Java 19 and 20, try Executors.newVirtualThreadPerTaskExecutor

@configuration
public class DubboConfig {
@bean
public ExecutorService virtualThreadExecutor() {
return Executors.newVirtualThreadPerTaskExecutor();
}
}
dubbo:
protocol:
name: dubbo
port: 20880
dispatcher: all
threadpool: cached
# 关键配置:使用虚拟线程
executor: virtualThreadExecutor

是否可以兼容springboot的yml虚拟线程开关呢 在dubbo-spring-boot-starter里 这样是可以兼容jdk17和jdk21的只需要一个开关

@JavaLionLi
Copy link
Contributor Author

#15158

@JavaLionLi
Copy link
Contributor Author

dubbo:
  protocol:
    name: dubbo
    port: 20880
    threadpool: virtual

上面说的配置不对 直接配线程池类型为虚拟线程即可

@github-project-automation github-project-automation bot moved this from Todo to Done in Dubbo Board Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Archived in project
Development

No branches or pull requests

2 participants