在一个模块里,同时有消费者和生产者。然后服务器启动,生产者可以运行,但是消费者就是没有反应。
另起一个main函数测试了下,发现其中定义的消费者可以正常工作。所以推断是我配置文件里的消费者有问题。
经过花式排查和重试,发现:
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
如果依赖使用的是这个,此时ContainerProperties配置文件中起class文件在:
<bean iclass="org.springframework.kafka.listener.config.ContainerProperties">
而使用
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
其ContainerProperties配置文件中起class文件在:
<bean iclass="org.springframework.kafka.listener.ContainerProperties">
版本不同,所在位置不同。
这里我将我的 2.2.0.RELEASE 换为 2.1.0.RELEASE 后,消费者生效。