From 6bc177d506dc9f3d6390c383e3c0b60372dec566 Mon Sep 17 00:00:00 2001 From: ialbert Date: Tue, 23 Aug 2022 17:42:17 +0300 Subject: [PATCH] kafka settings constants --- .../messaging/config/KafkaProducerFactory.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/config/KafkaProducerFactory.java b/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/config/KafkaProducerFactory.java index b8558d665..059dfb381 100644 --- a/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/config/KafkaProducerFactory.java +++ b/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/config/KafkaProducerFactory.java @@ -13,22 +13,22 @@ public class KafkaProducerFactory { Properties kafkaProps = new Properties(); //Assign localhost id - kafkaProps.put("bootstrap.servers", kafkaSettings.getBootstrapServers()); + kafkaProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaSettings.getBootstrapServers()); //Set acknowledgements for producer requests. - kafkaProps.put("acks", kafkaSettings.getAcks()); + kafkaProps.put(ProducerConfig.ACKS_CONFIG, kafkaSettings.getAcks()); //If the request fails, the producer can automatically retry, - kafkaProps.put("retries", kafkaSettings.getRetries()); + kafkaProps.put(ProducerConfig.RETRIES_CONFIG, kafkaSettings.getRetries()); //Specify buffer size in config - kafkaProps.put("batch.size", kafkaSettings.getBatchSize()); + kafkaProps.put(ProducerConfig.BATCH_SIZE_CONFIG, kafkaSettings.getBatchSize()); //Reduce the no of requests less than 0 - kafkaProps.put("linger.ms", kafkaSettings.getLingerMs()); + kafkaProps.put(ProducerConfig.LINGER_MS_CONFIG, kafkaSettings.getLingerMs()); //The buffer.memory controls the total amount of memory available to the producer for buffering. - kafkaProps.put("buffer.memory", kafkaSettings.getBufferMemory()); - kafkaProps.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + kafkaProps.put(ProducerConfig.BUFFER_MEMORY_CONFIG, kafkaSettings.getBufferMemory()); + kafkaProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); kafkaProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class.getName()); // kafkaProps.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); //ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());