创建主题失败","exception":"\norg.apache.kafka.common.errors.UnsupportedVersionException

Failed to create topics","exception":"\norg.apache.kafka.common.errors.UnsupportedVersionException

{
   "mdc":{
      
   },
   "timestamp":"2021-05-11 11:48:04.055",
   "level":"ERROR",
   "logger":"org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner",
   "message":"Failed to create topics",
   "exception":"\"\norg.apache.kafka.common.errors.UnsupportedVersionException: Creating topics with default partitions/replication factor are only supported in CreateTopicRequest version 4+. The following topics need values for partitions and replicas:"

当我收到此错误时,请建议需要进行哪些更改。

我看你是新来的。对于这样的问题,您应该始终包含版本信息和完整堆栈跟踪。

将您的代理升级到 >= 2.4 或设置活页夹复制因子 属性。

https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/commit/4161f875ede0446ab1d485730c51e6a2c5baa37a

  • Change default replication factor to -1

Binder now uses a default value of -1 for replication factor signaling the broker to use defaults. Users who are on Kafka brokers older than 2.4, need to set this to the previous default value of 1 used in the binder.

In either case, if there is an admin policy that requires replication factor > 1, then that value must be used instead.

用非负值覆盖默认复制因子 (-1) 解决了我的问题。

spring.cloud.stream.kafka.binder.replication-factor=1

application.yaml 文件使用:

spring.cloud.stream.kafka.binder.replicationFactor: 1