线程池扩展

扩展说明

服务提供者的线程池实现策略。当服务器收到请求时,需要在线程池中创建一个线程来执行服务提供者的业务逻辑。

扩展点

org.apache.dubbo.common.threadpool.ThreadPool

扩展配置

<dubbo:protocol threadpool="xxx" />
<!-- Default value setting, when <dubbo:protocol> does not configure threadpool, use this configuration -->
<dubbo:provider threadpool="xxx" />

已知扩展

  • org.apache.dubbo.common.threadpool.FixedThreadPool
  • org.apache.dubbo.common.threadpool.CachedThreadPool

扩展示例

Maven 项目结构

src
 |-main
    |-java
        |-com
            |-xxx
                |-XxxThreadPool.java (implement ThreadPool interface)
    |-resources
        |-META-INF
            |-dubbo
                |-org.apache.dubbo.common.threadpool.ThreadPool (plain text file, content: xxx=com.xxx.XxxThreadPool)

XxxThreadPool.java

package com.xxx;
 
import org.apache.dubbo.common.threadpool.ThreadPool;
import java.util.concurrent.Executor;
 
public class XxxThreadPool implements ThreadPool {
    public Executor getExecutor() {
        //...
    }
}

META-INF/dubbo/org.apache.dubbo.common.threadpool.ThreadPool

xxx=com.xxx.XxxThreadPool

上次修改时间:2023 年 1 月 2 日:增强英文文档 (#1798) (95a9f4f6c1c)