|
|
@ -18,6 +18,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
|
|
|
import org.springframework.core.task.TaskDecorator;
|
|
|
|
import org.springframework.core.task.TaskDecorator;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
@ -102,7 +103,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
|
|
|
|
.dynamicPool()
|
|
|
|
.dynamicPool()
|
|
|
|
.workQueue(workQueue)
|
|
|
|
.workQueue(workQueue)
|
|
|
|
.threadFactory(threadPoolId)
|
|
|
|
.threadFactory(threadPoolId)
|
|
|
|
.executeTimeOut(executorProperties.getExecuteTimeOut())
|
|
|
|
.executeTimeOut(Optional.ofNullable(executorProperties.getExecuteTimeOut()).orElse(0L))
|
|
|
|
.poolThreadSize(executorProperties.getCorePoolSize(), executorProperties.getMaximumPoolSize())
|
|
|
|
.poolThreadSize(executorProperties.getCorePoolSize(), executorProperties.getMaximumPoolSize())
|
|
|
|
.keepAliveTime(executorProperties.getKeepAliveTime(), TimeUnit.SECONDS)
|
|
|
|
.keepAliveTime(executorProperties.getKeepAliveTime(), TimeUnit.SECONDS)
|
|
|
|
.rejected(RejectedTypeEnum.createPolicy(executorProperties.getRejectedHandler()))
|
|
|
|
.rejected(RejectedTypeEnum.createPolicy(executorProperties.getRejectedHandler()))
|
|
|
@ -132,7 +133,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
|
|
|
|
|
|
|
|
|
|
|
|
dynamicThreadPoolWrap.setExecutor(newDynamicPoolExecutor);
|
|
|
|
dynamicThreadPoolWrap.setExecutor(newDynamicPoolExecutor);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
log.error("Failed to initialize thread pool configuration. error message :: {}", ex.getMessage());
|
|
|
|
log.error("Failed to initialize thread pool configuration. error :: {}", ex);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
if (Objects.isNull(dynamicThreadPoolWrap.getExecutor())) {
|
|
|
|
if (Objects.isNull(dynamicThreadPoolWrap.getExecutor())) {
|
|
|
|
dynamicThreadPoolWrap.setExecutor(CommonDynamicThreadPool.getInstance(threadPoolId));
|
|
|
|
dynamicThreadPoolWrap.setExecutor(CommonDynamicThreadPool.getInstance(threadPoolId));
|
|
|
|