提交 a5d6c16f 作者: gh

延时线程池

上级 e0c5897b
......@@ -42,4 +42,20 @@ public class ThreadConfig {
executor.initialize();
return executor;
}
@Bean("delayCustomerExecutor")
public ThreadPoolTaskExecutor delayCustomerExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(15);
executor.setMaxPoolSize(50);
executor.setQueueCapacity(6);
executor.setKeepAliveSeconds(100);
executor.setThreadNamePrefix("Async-DelayCustomer-");
// 线程池对拒绝任务的处理策略
// CallerRunsPolicy:由调用线程(提交任务的线程)处理该任务
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化
executor.initialize();
return executor;
}
}
package com.yaoyaozw.customer.service.wechat.service;
import cn.hutool.core.util.ObjectUtil;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.entity.AuthorizerToken;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
......@@ -53,7 +52,7 @@ public class WeChatServiceImpl implements WeChatService{
private WeChatRestService weChatRestService;
@Async("myExecutor")
@Async("delayCustomerExecutor")
@Override
public Future<CustomerDelayPublish> sendCustomerDelayMessage( AuthorizerToken authorizerToken, CustomerDelayPublish user,
Map<Integer,List<CustomerDelayItemVO>> delaySortMap,
......@@ -65,7 +64,7 @@ public class WeChatServiceImpl implements WeChatService{
if (sendCustomerDelays!=null){
//找付费类型
List<CustomerDelayItemVO> collect = sendCustomerDelays.stream().filter(a -> a.getIsPay().equals(-1) || user.getPayType().equals(a.getIsPay()) ).collect(Collectors.toList());
List<CustomerDelayItemVO> collect = sendCustomerDelays.stream().filter(a -> a.getIsPay().equals(-1)||user.getPayType().equals(a.getIsPay()) ).collect(Collectors.toList());
if (!collect.isEmpty()){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论