confluent kafka topic consume¶
Description¶
Consume messages from a Kafka topic.
confluent kafka topic consume <topic> [flags]
Consume messages from a Kafka topic. Configuration and command guide: https://docs.confluent.io/confluent-cli/current/cp-produce-consume.html.
confluent kafka topic consume <topic> [flags]
Flags¶
--group string Consumer group ID. (default "confluent_cli_consumer_<uuid>")
-b, --from-beginning Consume from beginning of the topic.
--value-format string Format of message value as string, avro, protobuf, or jsonschema. Note that schema references are not supported for avro. (default "string")
--print-key Print key of the message.
--delimiter string The delimiter separating each key and value. (default "\t")
--context-name string The Schema Registry context under which to lookup schema ID.
--sr-endpoint string Endpoint for Schema Registry cluster.
--sr-api-key string Schema registry API key.
--sr-api-secret string Schema registry API key secret.
--api-key string API key.
--api-secret string API key secret.
--cluster string Kafka cluster ID.
--context string CLI context name.
--environment string Environment ID.
--bootstrap string REQUIRED: List of broker hosts, formatted as "host" or "host:port". Separate hosts with comma.
--ca-location string REQUIRED: File or directory path to CA certificate(s) for SSL verifying the broker's key.
--username string SASL_SSL username for use with PLAIN mechanism.
--password string SASL_SSL password for use with PLAIN mechanism.
--cert-location string Path to client's public key (PEM) used for SSL authentication.
--key-location string Path to client's private key (PEM) used for SSL authentication.
--key-password string Private key passphrase for SSL authentication.
--protocol string Security protocol used to communicate with brokers. (default "SSL")
--sasl-mechanism string SASL_SSL mechanism used for authentication. (default "PLAIN")
--group string Consumer group ID.
-b, --from-beginning Consume from beginning of the topic.
--print-key Print key of the message.
--delimiter string The delimiter separating each key and value. (default "\t")
--value-format string Format of message value as string, avro, protobuf, or jsonschema. (default "string")
--sr-endpoint string The URL of the schema registry cluster.
-o, --output string Specify the output format as "human", "json", or "yaml". (default "human")
Global Flags¶
-h, --help Show help for this command.
-v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace).
Examples¶
Consume items from the “my_topic” topic and press “Ctrl+C” to exit.
confluent kafka topic consume -b my_topic
Consume message from topic “my_topic” with SSL protocol and SSL verification enabled (providing certificate and private key).
confluent kafka topic consume my_topic --protocol SSL --bootstrap "localhost:19091" --ssl-verification --ca-location ca-cert --cert-location client.pem --key-location client.key
Consume message from topic “my_topic” with SASL_SSL/OAUTHBEARER protocol enabled (using MDS token).
confluent kafka topic consume my_topic --protocol SASL_SSL --sasl-mechanism OAUTHBEARER --bootstrap "localhost:19091"
See Also¶
- confluent kafka topic - Manage Kafka topics.