by-crm/backend/src/main/java/com/bycrm/config/AsyncConfig.java
andy f400a93bdd feat: 新增pushplus微信推送新报备通知功能
实现pushplus微信推送新报备通知的全套功能:
- 新增通知服务接口与实现类
- 配置异步线程池避免阻塞主业务
- 补充application.yml推送配置项
- 添加管理员测试推送API接口
- 在报备创建事务提交后触发通知,确保仅成功提交的报备发送通知
2026-08-03 16:06:09 +08:00

35 lines
1.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.bycrm.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 异步任务配置:为消息推送等异步操作提供线程池。
*/
@Configuration
@EnableAsync
public class AsyncConfig {
/**
* pushplus 推送专用线程池。
* 满载时降级为调用线程同步执行CallerRunsPolicy宁可变慢也不丢弃推送任务。
*/
@Bean("pushplusExecutor")
public Executor pushplusExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(4);
executor.setQueueCapacity(100);
executor.setThreadNamePrefix("pushplus-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.initialize();
return executor;
}
}