kafka-python producer

A line-oriented console producer. Reads lines from standard input and publishes each one as a record to the configured topic.

Examples

# Publish a single message
echo "hello kafka" | kafka-python producer -b localhost:9092 -t my-topic

# Stream lines from a file
kafka-python producer -b localhost:9092 -t my-topic < messages.txt

Reference

Kafka console producer

usage: kafka-python producer [-h] -b BOOTSTRAP_SERVERS [-S SECURITY_PROTOCOL]
                             [-M SASL_MECHANISM] [-U SASL_USER]
                             [-P SASL_PASSWORD] [-l LOG_LEVEL]
                             [-L ENABLE_LOGGER] [-D DISABLE_LOGGER]
                             [-C EXTRA_CONFIG] -t TOPIC [--encoding ENCODING]

connection

-b, --bootstrap-servers

host:port for cluster bootstrap server. Can be provided multiple times.

-S, --security-protocol

PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL

Default: 'PLAINTEXT'

-M, --sasl-mechanism

PLAIN, GSSAPI, OAUTHBEARER, SCRAM-SHA-256, SCRAM-SHA-512

Default: 'PLAIN'

-U, --sasl-user
-P, --sasl-password

logging

-l, --log-level

logging level, passed to logging.basicConfig

Default: 'CRITICAL'

-L, --enable-logger

enable a specific logger. Can be provided multiple times. If not provided, all loggers are enabled

-D, --disable-logger

disable a specific logger. Can be provided multiple times.

extended

-C, --extra-config

additional configuration properties for client in “key=val” format. Can be provided multiple times.

producer options

-t, --topic

publish to topic

--encoding

byte encoding for produced messages

Default: 'utf-8'