1、修改@KafkaListener id topic为固定值

This commit is contained in:
Hao Miao
2024-02-01 16:02:24 +08:00
parent 6cab8d2fa5
commit 5af92950ee
2 changed files with 2 additions and 2 deletions

View File

@@ -8,6 +8,6 @@ import org.springframework.context.annotation.Configuration;
public class KafkaTopicConfig { public class KafkaTopicConfig {
@Bean @Bean
public NewTopic batchTopic() { public NewTopic batchTopic() {
return new NewTopic("testTopic", 4, (short) 1); return new NewTopic("topic-alert", 4, (short) 1);
} }
} }

View File

@@ -15,7 +15,7 @@ public class KafkaConsumerService {
this.alertMessageService = alertMessageService; this.alertMessageService = alertMessageService;
} }
@KafkaListener(id = "${spring.kafka.consumer.group-id}", topics = "${spring.kafka.consumer.topic-name}", @KafkaListener(id = "AlertGroup", topics = "topic-alert",
errorHandler = "myKafkaListenerErrorHandler", errorHandler = "myKafkaListenerErrorHandler",
properties = {"spring.json.value.default.type=com.realtime.protection.configuration.entity.alert.AlertMessage"}) properties = {"spring.json.value.default.type=com.realtime.protection.configuration.entity.alert.AlertMessage"})
public void consume(AlertMessage alert, Acknowledgment ack) { public void consume(AlertMessage alert, Acknowledgment ack) {