📥Kafka Producer
Also known as Producer (Kafka), Kafka Producer Client
A program that writes events into Kafka. It does not know who reads them.
Think of it like
It is like a person posting letters through a mail slot. They drop them in and walk on.
Example
A shop's checkout is a producer. Each order goes to the orders topic. The key is the customer ID, so each customer's orders stay in order.
Why it matters
The producer picks the key, and the key decides the order. A careless key can scramble events that must stay in line.
Definition
Example code
console
$ bin/kafka-console-producer.sh --topic orders --bootstrap-server localhost:9092
> order 1001 placed
> order 1002 placedCommon mistake
Key takeaways
- 1Key picks the partition. Same key, same partition.
- 2Waits for a yes. Brokers confirm each write.
- 3Knows no readers. Writers and readers stay apart.