增加线程超时
This commit is contained in:
@@ -182,7 +182,7 @@ public class TmNameplateCorpusServiceImpl extends ServiceImpl<TmNameplateCorpusM
|
||||
// 获取许可 - 如果没有可用许可会阻塞等待
|
||||
// 获取许可 - 如果没有可用许可会阻塞等待
|
||||
// 修改为带超时的获取许可方式,超时时间为1分钟
|
||||
if (!semaphore.tryAcquire(1, TimeUnit.MINUTES)) {
|
||||
if (!semaphore.tryAcquire(5, TimeUnit.MINUTES)) {
|
||||
log.warn("获取许可超时,跳过执行任务");
|
||||
return;
|
||||
}
|
||||
@@ -206,7 +206,11 @@ public class TmNameplateCorpusServiceImpl extends ServiceImpl<TmNameplateCorpusM
|
||||
try {
|
||||
log.info("铭牌语料可用许可授权数,画像场景={}", semaphore.availablePermits());
|
||||
// 获取许可 - 如果没有可用许可会阻塞等待
|
||||
semaphore.acquire();
|
||||
// 修改为带超时的获取许可方式,超时时间为1分钟
|
||||
if (!semaphore.tryAcquire(5, TimeUnit.MINUTES)) {
|
||||
log.warn("获取许可超时,跳过执行任务");
|
||||
return;
|
||||
}
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
|
||||
@@ -259,7 +263,6 @@ public class TmNameplateCorpusServiceImpl extends ServiceImpl<TmNameplateCorpusM
|
||||
public void sendNameplateLto(JSONObject execDifyFlow, String aiAnalysisRequestId, TmNameplateCorpus tmNameplateCorpus, String businessType) {
|
||||
|
||||
try {
|
||||
|
||||
log.info("铭牌sendNameplateLto toJSONString :{}", execDifyFlow);
|
||||
log.info("tmNameplateCorpus.tostrign:{}", tmNameplateCorpus);
|
||||
|
||||
|
||||
@@ -125,8 +125,8 @@ public class TmOdsVdqwMessagearchivingServiceImpl extends ServiceImpl<TmOdsVdqwM
|
||||
int totalPages = PageDto.getTotalPages(total, pageSize);
|
||||
|
||||
// 获取消息列表
|
||||
int optimalThreadPoolSize = Runtime.getRuntime().availableProcessors() + 1;
|
||||
log.info("QiWeiCorpus企微处理总数据量:{},设置线程数:{},获取的线程数:{}",totalPages,threadNum,optimalThreadPoolSize);
|
||||
|
||||
log.info("QiWeiCorpus企微处理总数据量:{},设置线程数:{}",totalPages,threadNum);
|
||||
// 创建线程池
|
||||
ExecutorService executor = Executors.newFixedThreadPool(threadNum); // 根据需求调整线程池大小
|
||||
|
||||
|
||||
Reference in New Issue
Block a user