添加日志 定位高消费问题
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user