From ea4adcdeb70eae7ee486618bad2292109ae8cb36 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 23 Oct 2025 16:11:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(kafka):=20=E7=A7=BB=E9=99=A4Kafka=E9=9B=86?= =?UTF-8?q?=E6=88=90=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了KafkaIntegrationService类及其相关逻辑 - 移除了Kafka消息发送和连接测试功能 - 清理了未实现的预留接口方法 - 移除了相关的配置属性获取方法 --- .../service/KafkaIntegrationService.java | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/main/java/com/ycwl/basic/integration/kafka/service/KafkaIntegrationService.java diff --git a/src/main/java/com/ycwl/basic/integration/kafka/service/KafkaIntegrationService.java b/src/main/java/com/ycwl/basic/integration/kafka/service/KafkaIntegrationService.java deleted file mode 100644 index 9cb81b09..00000000 --- a/src/main/java/com/ycwl/basic/integration/kafka/service/KafkaIntegrationService.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.ycwl.basic.integration.kafka.service; - -import com.ycwl.basic.integration.kafka.config.KafkaIntegrationProperties; -import com.ycwl.basic.integration.kafka.dto.KafkaMessage; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.stereotype.Service; - -@Slf4j -@Service -@RequiredArgsConstructor -@ConditionalOnProperty(name = "kafka.enabled", havingValue = "true") -public class KafkaIntegrationService { - - private final KafkaTemplate kafkaTemplate; - private final KafkaIntegrationProperties kafkaProperties; - - /** - * 测试Kafka连接 - */ - public boolean testConnection() { - try { - log.info("Testing Kafka connection to: {}", kafkaProperties.getBootstrapServers()); - - // 尝试获取元数据以测试连接 - var metadata = kafkaTemplate.getProducerFactory().createProducer().partitionsFor("test-topic"); - log.info("Kafka connection test successful"); - return true; - } catch (Exception e) { - log.error("Kafka connection test failed", e); - return false; - } - } - - /** - * 发送消息(预留接口,暂不实现具体逻辑) - */ - public void sendMessage(String topic, String key, KafkaMessage message) { - log.info("Kafka message sending is not implemented yet. Topic: {}, Key: {}", topic, key); - // TODO: 后续实现具体的消息发送逻辑 - } - - /** - * 获取Kafka配置信息 - */ - public KafkaIntegrationProperties getKafkaProperties() { - return kafkaProperties; - } -} \ No newline at end of file