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