定位高消费问题

This commit is contained in:
ZLI263
2025-09-19 12:16:58 +08:00
parent e7e2233e93
commit 31af84f7da

View File

@@ -41,7 +41,7 @@ public class NameplateKafkaConsumer {
@Autowired
@Resource(name = "threadPoolTaskExecutor")
private ThreadPoolTaskExecutor executor;
private Semaphore semaphore = new Semaphore(10); // 限制并发数
private Semaphore semaphore = new Semaphore(2); // 限制并发数
@KafkaListener(topics = "${analyticCenterKafka.consumer.topic}", // = smart_assistant_nameplate_topic
groupId = "${analyticCenterKafka.consumer.group}" , //smart_assistant_nameplate_topic_group
@@ -68,7 +68,11 @@ public class NameplateKafkaConsumer {
tmNameplateCorpus.getData().forEach(nameplate ->
CompletableFuture.runAsync(() -> {
try {
log.info(String.format("尝试获取许可,当前可用许可数: %d",
semaphore.availablePermits()));
semaphore.acquire(); // 获取许可
log.info(String.format("获取许可后,当前可用许可数:: %d",
semaphore.availablePermits()));
tmNameplateCorpusService.processItem(nameplate);
} catch (Exception e) {
log.error("corpusPortrait画像铭牌异步任务执行失败", e);