|
|
@ -135,7 +135,7 @@ spring:
|
|
|
|
|
|
|
|
|
|
|
|
## ThreadPoolExecutor 适配
|
|
|
|
## ThreadPoolExecutor 适配
|
|
|
|
|
|
|
|
|
|
|
|
添加线程池配置类,通过 `@DynamicThreadPool` 注解修饰。`threadPoolId` 为服务端创建的线程池 ID。
|
|
|
|
添加线程池配置类,通过 `@SpringDynamicThreadPool` 注解修饰。`threadPoolId` 为服务端创建的线程池 ID。
|
|
|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
```java
|
|
|
|
package cn.hippo4j.example;
|
|
|
|
package cn.hippo4j.example;
|
|
|
@ -149,28 +149,16 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
public class ThreadPoolConfig {
|
|
|
|
public class ThreadPoolConfig {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@SpringDynamicThreadPool
|
|
|
|
@DynamicThreadPool
|
|
|
|
|
|
|
|
public ThreadPoolExecutor messageConsumeDynamicExecutor() {
|
|
|
|
public ThreadPoolExecutor messageConsumeDynamicExecutor() {
|
|
|
|
String threadPoolId = "message-consume";
|
|
|
|
String threadPoolId = "message-consume";
|
|
|
|
ThreadPoolExecutor messageConsumeDynamicExecutor = ThreadPoolBuilder.builder()
|
|
|
|
return ThreadPoolBuilder.buildDynamicPoolById(threadPoolId);
|
|
|
|
.threadFactory(threadPoolId)
|
|
|
|
|
|
|
|
.threadPoolId(threadPoolId)
|
|
|
|
|
|
|
|
.dynamicPool()
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
return messageConsumeDynamicExecutor;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@SpringDynamicThreadPool
|
|
|
|
@DynamicThreadPool
|
|
|
|
|
|
|
|
public ThreadPoolExecutor messageProduceDynamicExecutor() {
|
|
|
|
public ThreadPoolExecutor messageProduceDynamicExecutor() {
|
|
|
|
String threadPoolId = "message-produce";
|
|
|
|
String threadPoolId = "message-produce";
|
|
|
|
ThreadPoolExecutor messageProduceDynamicExecutor = ThreadPoolBuilder.builder()
|
|
|
|
return ThreadPoolBuilder.buildDynamicPoolById(threadPoolId);
|
|
|
|
.threadFactory(threadPoolId)
|
|
|
|
|
|
|
|
.threadPoolId(threadPoolId)
|
|
|
|
|
|
|
|
.dynamicPool()
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
return messageProduceDynamicExecutor;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|