A Kafka producer publishes records to Kafka topics. It sends records to brokers, which store them for independent consumers. This client is the entry point for getting application data into an event-streaming system. section 1.4.3 section 4.1
KafkaProducer receives configuration properties and creates ProducerRecord objects containing the topic, key, and value. Calling send() is asynchronous: the producer batches records and sends them when its buffer is full or the send time arrives. section 4.2
A practical producer flow is:
- Fetch or generate application records, such as point-of-sale transactions. section 4.2
- Map each domain object into a ProducerRecord with a topic, key, and value. section 4.2
- Pass each record to KafkaProducer.send() and handle callback metadata or exceptions. section 4.2
- Use schemas and compatible serializers when producers and consumers share structured domain data. section 3.9
Publishing sales transactions
A wholesale company receives transaction data containing product, price, quantity, timestamp, and customer fields. A Java producer turns each ProductTransaction into a ProducerRecord keyed by customer name, sends it asynchronously, and logs either the resulting offset and timestamp or the production error. section 4.2
Figure 1.6 Producers write records into Kafka, and consumers read records.
Use the producer-consumer flow diagram to distinguish producers writing records into Kafka from consumers reading them. section 1.4.3

