|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
package com.github.dynamic.threadpool.example.config;
|
|
|
|
|
|
|
|
|
|
import com.github.dynamic.threadpool.starter.core.DynamicThreadPool;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.core.DynamicThreadPoolExecutor;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrapper;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
@ -23,26 +23,26 @@ import static com.github.dynamic.threadpool.example.constant.GlobalTestConstant.
|
|
|
|
|
public class ThreadPoolConfig {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@link DynamicThreadPoolWrap} 完成 Server 端订阅配置功能.
|
|
|
|
|
* {@link DynamicThreadPoolWrapper} 完成 Server 端订阅配置功能.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public DynamicThreadPoolWrap messageCenterConsumeThreadPool() {
|
|
|
|
|
return new DynamicThreadPoolWrap(MESSAGE_CONSUME);
|
|
|
|
|
public DynamicThreadPoolWrapper messageCenterDynamicThreadPool() {
|
|
|
|
|
return new DynamicThreadPoolWrapper(MESSAGE_CONSUME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过 {@link DynamicThreadPool} 修饰 {@link CustomThreadPoolExecutor} 完成 Server 端订阅配置功能.
|
|
|
|
|
* 通过 {@link DynamicThreadPool} 修饰 {@link DynamicThreadPoolExecutor} 完成 Server 端订阅配置功能.
|
|
|
|
|
* <p>
|
|
|
|
|
* 由动态线程池注解修饰后, IOC 容器中保存的是 {@link CustomThreadPoolExecutor}
|
|
|
|
|
* 由动态线程池注解修饰后, IOC 容器中保存的是 {@link DynamicThreadPoolExecutor}
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
@DynamicThreadPool
|
|
|
|
|
public ThreadPoolExecutor customThreadPoolExecutor() {
|
|
|
|
|
return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).isCustomPool(true).build();
|
|
|
|
|
public ThreadPoolExecutor dynamicThreadPoolExecutor() {
|
|
|
|
|
return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).dynamicPool().build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|