-
Book Overview & Buying
-
Table Of Contents
Fast Data Processing Systems with SMACK Stack
By :
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:
KafkaProducer <K, V> in org.apache.kafka.clients.producer.KafkaProducerKafka Producer is a type of Java Generic written in Scala, K specifies the type of the partition key and V specifies the message value.
ProducerRecord: The class is ProducerRecord <K, V> in org.apache.kafka.clients.producer.ProducerRecordThis class encapsulates the data required for establishing the connection with the brokers (broker list...