kafka-console-producer.sh publishes records to a Kafka topic from console input. It is useful for testing a price-change flow: connect to a local broker, select products.prices.changelog, and send each update as a message. section 2.2
Pipe one record into a topic
echo "coffee pads 10" | kafka-console-producer.sh --topic products.prices.changelog --bootstrap-server localhost:9092 sends one line as a message. The producer prints no success confirmation when input is piped, so verify delivery with a consumer. section 2.2
Interactive mode sends one message for every line entered. The process continues until Ctrl-D sends EOF; a consumer running in another terminal can display new records promptly. section 2.4
Practical operating points:
- Use --topic to choose the destination and --bootstrap-server localhost:9092 to connect to the local Kafka cluster. section 2.2
- Run multiple producer instances to represent departments writing different product updates in parallel. section 2.4
- Pair the producer with independent consumers to observe live records or replay retained history with --from-beginning. section 2.4
- Expect connectivity errors when Kafka is unavailable; Confluent distributions omit .sh, and Windows users can use .bat scripts or WSL. section 2.0 section 2.2
Shows the smallest complete command for publishing a piped record to a topic. section 2.2
# Don't forget: use Ctrl-D to stop the producer
$ kafka-console-producer.sh \
--topic products.prices.changelog \
--bootstrap-server localhost:9092
Shows the interactive invocation used to type successive records and stop with Ctrl-D. section 2.4

