spring boot2整合kafka及遇到Exception thrown when sending a message with key=’null’问题
最近在学习spring boot2和kafka。就用学着使用spring boot2与kafka集成。项目环境
- 开发工具:IDEA
- spring kafka :2.1.6.RELEASE
- spring boot2:2.0.2.RELEASE
- Apache kafka:2.11-1.0.0
项目的github地址:https://github.com/sweetcczhang/springkafka
项目目录

application.properties文件
#kafka server address spring.kafka.bootstrap-servers=10.108.208.51:9092 # Provider spring.kafka.producer.retries=0 spring.kafka.producer.batch-size=16384 # 指生产者的key和value的编码方式 spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer # Consumer #消费者组 spring.kafka.consumer.group-id=test-consumer-group spring.kafka.consumer.auto-offset-reset=earliest # 指定消费者的解码方式 spring.kafka.consumer</

本文介绍了在Spring Boot2项目中整合Kafka时遇到的'Exception thrown when sending a message with key='null''问题及其解决方案。项目使用了spring kafka 2.1.6.RELEASE和Spring Boot 2.0.2.RELEASE,通过配置文件和代码展示了如何设置生产者和消费者。在实际运行中,由于服务器hosts配置不正确导致问题,最终通过修正hosts配置,将节点名与服务器IP对应,成功解决了问题。
最低0.47元/天 解锁文章
4178

被折叠的 条评论
为什么被折叠?



