mirror of https://github.com/longtai-cn/hippo4j
parent
89893c749c
commit
5bc468d082
@ -0,0 +1,36 @@
|
|||||||
|
package cn.hippo4j.example.server.config;
|
||||||
|
|
||||||
|
import cn.hippo4j.core.executor.DynamicThreadPool;
|
||||||
|
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class DynamicThreadPoolConfig {
|
||||||
|
|
||||||
|
@Bean(name = "messagePool")
|
||||||
|
@DynamicThreadPool
|
||||||
|
public ThreadPoolExecutor messageConsumerDynamicExecutor(){
|
||||||
|
String poolId = "message-pool";
|
||||||
|
ThreadPoolExecutor messagePool = ThreadPoolBuilder.builder()
|
||||||
|
.threadPoolId(poolId)
|
||||||
|
.threadFactory(poolId)
|
||||||
|
.dynamicPool()
|
||||||
|
.build();
|
||||||
|
return messagePool;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "goodsPool")
|
||||||
|
@DynamicThreadPool
|
||||||
|
public ThreadPoolExecutor goodsDynamicExecutor(){
|
||||||
|
String poolId = "goods-pool";
|
||||||
|
ThreadPoolExecutor goodsPool = ThreadPoolBuilder.builder()
|
||||||
|
.threadPoolId(poolId)
|
||||||
|
.threadFactory(poolId)
|
||||||
|
.dynamicPool()
|
||||||
|
.build();
|
||||||
|
return goodsPool;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue