Search code examples
javaapache-kafkaspring-kafka

NotEnoughReplicasException: Messages are rejected since there are fewer in-sync replicas than required


l have 5 kafka broker. And in my producer app, my configs is like below: Interesting part is that, after getting this exception 2 times, in third time message is producing to topic.

spring:
  kafka:
    streams:
      replication-factor: 3
    properties:
      min.insync.replicas: 2
    producer:
      acks: "all"
      batch-size: 1
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
      compression-type: "lz4"
      retries: 2
      properties:
        linger.ms: 1
        request:
          timeout:
            ms: 60000

So, l tried to assign different count for replication-factor and min.insync.replicas.


Solution

  • min.insync.replicas and replication.factor are both Topic Configs, not a Kafka (Streams) client property.

    From Spring Kafka , you can use @Bean NewTopic to define Kafka topic resources with their configurations.


    Your error probably went away because the cluster had healed itself, while your app was retrying the request. You should look at the broker server logs rather than your app's.