我运行一个生产者并使用以下代码引发异常。
@GetMapping("/send")
public ResultVo send(@RequestParam(value = "content") String content) {
return new ResultVo(kafkaTemplate.send("hello-topic", 0, "test", content));
}
2023-08-07 21:00:12.330 ERROR 1508 --- [ad | producer-1] o.s.k.support.LoggingProducerListener : Exception thrown when sending a message with key='test' and payload='test content' to topic hello-topic and partition 0:
org.apache.kafka.common.errors.InvalidRequestException: Cannot append records to read-only mirror topic
虽然生产者不起作用,但我写了一个消费者,可以正常获取消息。
@KafkaListener(topics = "hello-topic", groupId = "hello-group")
public void handleMessage(String content) {
log.info("{}", content);
}
您需要找到它们的镜像源,然后生成到该集群/主题。