feat(mix): 添加 ICE 异步提交专用线程池并注册 BouncyCastle 安全提供者
Some checks failed
Build and Deploy / deploy (push) Has been cancelled

为混剪任务配置增加两个关键基础设施:创建 ICE 异步提交专用线程池(核心 4 线程,最大 10 线程,使用 CallerRunsPolicy 拒绝策略),并注册 BouncyCastle 安全提供者以满足 ICE SDK 签名需求。这为混剪任务的异步执行提供了可靠的并发控制和安全依赖。
This commit is contained in:
2026-06-03 22:45:38 +08:00
parent e99c0806de
commit 703cc2697e

View File

@@ -1,14 +1,56 @@
package cn.iocoder.yudao.module.tik.mix.config;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.security.Security;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 混剪任务配置
*
* @author 芋道源码
*/
@Slf4j
@Configuration
@EnableScheduling
public class MixTaskConfig {
/**
* ICE 异步提交专用线程池
* <p>
* 核心线程 4最大线程 10空闲 60s 回收,有界队列 200
* 拒绝策略调用者线程执行CallerRunsPolicy确保任务不丢失
*/
@Bean("iceSubmitExecutor")
public ThreadPoolExecutor iceSubmitExecutor() {
return new ThreadPoolExecutor(
4, 10,
60, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(200),
new ThreadPoolExecutor.CallerRunsPolicy()
);
}
/**
* 注册 BouncyCastle 安全提供者
* <p>
* ICE SDK 底层依赖 BC 做 API 请求签名({@code org.bouncycastle.crypto.Digest})。
* Java 17 已内置 JCE不再存在嵌套 JAR 签名校验失败的问题,直接注册即可。
*/
static {
try {
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
Security.addProvider(new BouncyCastleProvider());
log.info("[MixTask] BouncyCastle Provider 已注册");
}
} catch (Exception e) {
log.warn("[MixTask] BouncyCastle Provider 注册失败(如已存在则忽略): {}", e.getMessage());
}
}
}