Thread Pool Extension

Thread Pool Extension

Extension Description

The thread pool implementation strategy for service providers requires creating a thread in the thread pool to execute the service provider’s business logic when the server receives a request.

Extension Interface

org.apache.dubbo.common.threadpool.ThreadPool

Extension Configuration

  1. <dubbo:protocol threadpool="xxx" />
  2. <!-- Default value configuration, used when <dubbo:protocol> does not configure threadpool -->
  3. <dubbo:provider threadpool="xxx" />

Known Extensions

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

Extension Example

Maven project structure:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxThreadPool.java (implements ThreadPool interface)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.common.threadpool.ThreadPool (plain text file, content: xxx=com.xxx.XxxThreadPool)

XxxThreadPool.java:

  1. package com.xxx;
  2. import org.apache.dubbo.common.threadpool.ThreadPool;
  3. import java.util.concurrent.Executor;
  4. public class XxxThreadPool implements ThreadPool {
  5. public Executor getExecutor() {
  6. // ...
  7. }
  8. }

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

  1. xxx=com.xxx.XxxThreadPool

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)