Producers

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.

Producer API

First, we need to understand the classes needed to write a producer:

  • Producer: The producer class is KafkaProducer <K, V> in org.apache.kafka.clients.producer.KafkaProducer

Kafka Producer is a type of Java Generic written in Scala, K specifies the type of the partition key and ...

Get Fast Data Processing Systems with SMACK Stack now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.