멱등성 프로듀서
public ProducerFactory<String, ChatMessageRequestDTO> producerFactory() {
log.info("producerFactory Started ! ========");
log.info("producerFactory.bootstrapServers : {}", bootstrapServers);
Map<String, Object> configProps = new HashMap<>();
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
configProps.put(ProducerConfig.RETRIES_CONFIG, Integer.MAX_VALUE);
configProps.put(ProducerConfig.ACKS_CONFIG, "all");
configProps.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "zstd");
configProps.put(ProducerConfig.BATCH_SIZE_CONFIG, 16384);
configProps.put(ProducerConfig.LINGER_MS_CONFIG, 5);
configProps.put(ProducerConfig.BUFFER_MEMORY_CONFIG, 33554432);
configProps.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, 1048576);
configProps.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, 5000);
configProps.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, 3000);
configProps.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
return new DefaultKafkaProducerFactory<>(configProps);
}
Integer.MAX_VALUE
설정