Package api.mpba.rastvdmy.config
Class KafkaProducerConfig
java.lang.Object
api.mpba.rastvdmy.config.KafkaProducerConfig
This class is responsible for the configuration of Kafka producers.
It provides the necessary beans for creating Kafka producers.
The configuration properties are fetched from the application's properties file.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionkafkaTemplate
(org.springframework.kafka.core.ProducerFactory<String, String> producerFactory) This method provides a KafkaTemplate bean.This method provides the configuration for Kafka producers.This method provides a ProducerFactory bean.
-
Constructor Details
-
KafkaProducerConfig
public KafkaProducerConfig()
-
-
Method Details
-
producerConfig
This method provides the configuration for Kafka producers. It sets the bootstrap servers, key serializer and value serializer.- Returns:
- A map containing the configuration properties.
-
producerFactory
This method provides a ProducerFactory bean. The ProducerFactory is responsible for creating Kafka producers.- Returns:
- A new instance of DefaultKafkaProducerFactory.
-
kafkaTemplate
@Bean public org.springframework.kafka.core.KafkaTemplate<String,String> kafkaTemplate(org.springframework.kafka.core.ProducerFactory<String, String> producerFactory) This method provides a KafkaTemplate bean. The KafkaTemplate wraps a Producer instance and provides convenience methods for sending messages to Kafka topics.- Parameters:
producerFactory
- The producer factory.- Returns:
- A new instance of KafkaTemplate.
-