添加日志 定位高消费问题
This commit is contained in:
@@ -24,7 +24,7 @@ public class ExecutorConfig {
|
|||||||
private int maxPoolSize=12;
|
private int maxPoolSize=12;
|
||||||
|
|
||||||
// @Value("${task.pool.keepAliveSeconds}")
|
// @Value("${task.pool.keepAliveSeconds}")
|
||||||
private int keepAliveSeconds=12000;
|
private int keepAliveSeconds=6000000;
|
||||||
|
|
||||||
// @Value("${task.pool.queueCapacity}")
|
// @Value("${task.pool.queueCapacity}")
|
||||||
private int queueCapacity=20;
|
private int queueCapacity=20;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class NameplateKafkaConsumer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
@Resource(name = "threadPoolTaskExecutor")
|
@Resource(name = "threadPoolTaskExecutor")
|
||||||
private ThreadPoolTaskExecutor executor;
|
private ThreadPoolTaskExecutor executor;
|
||||||
private Semaphore semaphore = new Semaphore(2); // 限制并发数
|
private Semaphore semaphore = new Semaphore(10); // 限制并发数
|
||||||
|
|
||||||
@KafkaListener(topics = "${analyticCenterKafka.consumer.topic}", // = smart_assistant_nameplate_topic
|
@KafkaListener(topics = "${analyticCenterKafka.consumer.topic}", // = smart_assistant_nameplate_topic
|
||||||
groupId = "${analyticCenterKafka.consumer.group}" , //smart_assistant_nameplate_topic_group
|
groupId = "${analyticCenterKafka.consumer.group}" , //smart_assistant_nameplate_topic_group
|
||||||
@@ -70,14 +70,17 @@ public class NameplateKafkaConsumer {
|
|||||||
try {
|
try {
|
||||||
log.info(String.format("尝试获取许可,当前可用许可数: %d",
|
log.info(String.format("尝试获取许可,当前可用许可数: %d",
|
||||||
semaphore.availablePermits()));
|
semaphore.availablePermits()));
|
||||||
|
if (semaphore.availablePermits() == 0)
|
||||||
|
log.info("获取许可 失败,❌ 任务被中断");
|
||||||
semaphore.acquire(); // 获取许可
|
semaphore.acquire(); // 获取许可
|
||||||
log.info(String.format("获取许可后,当前可用许可数:: %d",
|
log.info(String.format("获取许可✅ 成功后,当前可用许可数:: %d",
|
||||||
semaphore.availablePermits()));
|
semaphore.availablePermits()));
|
||||||
tmNameplateCorpusService.processItem(nameplate);
|
tmNameplateCorpusService.processItem(nameplate);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("corpusPortrait画像铭牌异步任务执行失败", e);
|
log.error("corpusPortrait画像铭牌异步任务执行失败", e);
|
||||||
} finally {
|
} finally {
|
||||||
log.info("corpusPortrait 释放锁,availablePermits {}", semaphore.availablePermits());
|
log.info("corpusPortrait 释放锁,availablePermits {}", semaphore.availablePermits());
|
||||||
|
|
||||||
semaphore.release(); // 释放许可
|
semaphore.release(); // 释放许可
|
||||||
}
|
}
|
||||||
}, executor));
|
}, executor));
|
||||||
|
|||||||
Reference in New Issue
Block a user