Producers are applications that create messages and publish them to the broker. Normally, producers are: frontend applications, web pages, web services, backend services, proxies, and adapters to legacy systems. We can write Kafka producers in Java, Scala, C and Python.
The process begins when the producer connects to any live node and requests the metadata about the partitions leaders of a topic, to put the message directly to the partition lead broker.
First, we need to understand the classes needed to write a producer:
- Producer: The producer class is
KafkaProducer <K, V>in
Kafka Producer is a type of Java Generic written in Scala, K specifies the type of the partition key and ...