On a Java Spring application, I'm configuring a Producer to use Acks and must set min.insync.replicas parameter too.
I got it setup Acks using:
configProps.put(ProducerConfig.ACKS_CONFIG, kafkaAcks);
but I can't found the min.insync.replicas
property on ProducerConfig
. Looking on Kafka Spring Docs I not found the property related with min.insync.replicas
.
So, how I configure min.insync.replicas
on a Kafka Spring application?
@Bean
public KafkaTemplate<String, GenericRecord> kafkaTemplate() {
return new KafkaTemplate<>(producerFactory());
}
public ProducerFactory<String, GenericRecord> producerFactory() {
return new DefaultKafkaProducerFactory<>(getProducerGenericRecordConfigurations());
}
private Map<String, Object> getProducerGenericRecordConfigurations() {
Map<String, Object> configProps = new HashMap<>();
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaBootstrapServerUrl);
configProps.put(KafkaAvroDeserializerConfig.SCHEMA_REGISTRY_URL_CONFIG, schemaRegistryURL);
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class);
configProps.put(ProducerConfig.ACKS_CONFIG, kafkaAcks);
return configProps;
}
min.insync.replicas
is not a Producer configuration. It's a broker/topic setting.
You can set it at the broker level in your server.properties
files for your brokers.
Otherwise you can set it per topic, either at creation or by altering it.