添加日志 定位高消费问题

This commit is contained in:
ZLI263
2025-09-19 12:44:58 +08:00
parent 31af84f7da
commit 7855954497
2 changed files with 6 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ public class ExecutorConfig {
private int maxPoolSize=12;
// @Value("${task.pool.keepAliveSeconds}")
private int keepAliveSeconds=12000;
private int keepAliveSeconds=6000000;
// @Value("${task.pool.queueCapacity}")
private int queueCapacity=20;

View File

@@ -41,7 +41,7 @@ public class NameplateKafkaConsumer {
@Autowired
@Resource(name = "threadPoolTaskExecutor")
private ThreadPoolTaskExecutor executor;
private Semaphore semaphore = new Semaphore(2); // 限制并发数
private Semaphore semaphore = new Semaphore(10); // 限制并发数
@KafkaListener(topics = "${analyticCenterKafka.consumer.topic}", // = smart_assistant_nameplate_topic
groupId = "${analyticCenterKafka.consumer.group}" , //smart_assistant_nameplate_topic_group
@@ -70,14 +70,17 @@ public class NameplateKafkaConsumer {
try {
log.info(String.format("尝试获取许可,当前可用许可数: %d",
semaphore.availablePermits()));
if (semaphore.availablePermits() == 0)
log.info("获取许可 失败,❌ 任务被中断");
semaphore.acquire(); // 获取许可
log.info(String.format("获取许可后,当前可用许可数:: %d",
log.info(String.format("获取许可✅ 成功后,当前可用许可数:: %d",
semaphore.availablePermits()));
tmNameplateCorpusService.processItem(nameplate);
} catch (Exception e) {
log.error("corpusPortrait画像铭牌异步任务执行失败", e);
} finally {
log.info("corpusPortrait 释放锁availablePermits {}", semaphore.availablePermits());
semaphore.release(); // 释放许可
}
}, executor));