嗨,我们一直在使用旧的Spring版本和具有以下依赖关系的kafka 1.1
+--- org.springframework.boot:spring-boot-starter-web: -> 1.5.4.RELEASE (*)
+--- org.springframework.cloud:spring-cloud-starter-config: -> 1.3.1.RELEASE (*)
+--- org.springframework.cloud:spring-cloud-starter-bus-kafka: -> 1.3.1.RELEASE (*)
+--- org.springframework.cloud:spring-cloud-stream-binder-kafka: -> 1.2.1.RELEASE (*)
+--- org.apache.kafka:kafka-clients:0.11.0.2 (*)
+--- org.apache.kafka:kafka_2.11:0.11.0.2 (*)
我在application.yaml文件中具有以下配置
spring:
kafka:
properties.security.protocol: SSL
ssl:
key-password: ${ABC_KEY_PASSWORD}
keystore-location: file:${ABC_KEYSTORE}
keystore-password: ${ABC_KEYSTORE_PASSWORD}
truststore-location: file:${ABC_TRUSTSTORE}
truststore-password: ${ABC_TRUSTSTORE_PASSWORD}
consumer:
enable-auto-commit: false
cloud:
stream:
bindings:
feed_fcpostprocessor_event:
destination: app-fc-notification
binder: abckafka
group: app-fc-group
consumer:
partitioned: true
concurrency: 2
kafka:
binder:
brokers: ${ABC_BROKER_HOST:abc-kafka.aws.local:9092}
autoCreateTopics: true
autoAddPartitions: true
replicationFactor: 3
partitionCount: 2
bindings:
feed_fcpostprocessor_event:
consumer:
autoCommitOffset: false
binders:
abckafka:
type: kafka
我在stackoverflow中发现了link。答案有
首先,我不确定您对什么期望SpringApplication.exit(applicationContext,()-> 0);,但是你在本质上降低了整个应用程序的负担可能在那里运行。其次,您的邮件丢失是由于事实Kafka活页夹绝对不知道有例外发生,并且必须将消息放回主题。
这是否也就意味着Kafka不知道消费者不满意,在这种情况下,消费者没有任何交流。我本来以为会发生重新平衡,而且由于在kafka级别的enable-auto-commit和在绑定级别的autoCommitOffset被设置为false。该偏移量将不会提交,如果应用程序再次启动,它将从错过的最后一个偏移量开始,或者如果发生重新平衡,则其他使用者将从分区中其他使用者失败的偏移量中读取。
我相信我的问题不是重复的,而是要问的。如果有任何问题,请指出答案。否则,请阐明行为。谢谢
首先,即使不再支持Boot 1.5;您应该使用spring-kafka 1.3.11而不是1.1;多亏了KIP-62,它的线程模型更为简单。在1.3之前,为避免重新平衡,事情非常复杂。
但是,更好的是,您应该升级到所有项目的受支持版本,但至少要升级spring-kafka。