Important
You are viewing documentation for an older version of Confluent Platform. For the latest, click here.
confluent consume¶
Description¶
Consume data from topics. By default this command consumes non-Avro data from the Apache Kafka® cluster on the localhost.
For this command to work, you must configure the PATH
environment variable to point to the Confluent Platform bin
directory.
For reference on how to use Confluent CLI to produce to a topic, see confluent produce.
Usage¶
confluent consume <topicname> [--value-format avro] [other optional args]
Tip
For usage information, enter confluent help consume
.
Required Arguments¶
Name, shorthand | Default | Description |
---|---|---|
<topicname> |
Kafka topic to consume messages from |
Optional Arguments¶
Here are some common optional arguments. For a full list of optional arguments:
confluent help consume
Name, shorthand | Default | Description |
---|---|---|
--value-format avro |
Specify the topic data as Avro data. | |
--cloud |
Connect to Confluent Cloud using configuration file at default location $HOME/.ccloud/config |
|
--config <filename> |
Specify an alternate configuration file | |
--from-beginning |
latest |
Consume from the earliest message in the topic log |
--bootstrap-server |
localhost:9092 |
Kafka brokers to connect to. |
Examples¶
Consume Avro data from the beginning of topic called
mytopic1
on a development Kafka cluster on localhost. Assumes Confluent Schema Registry is listening athttp://localhost:8081
.confluent consume mytopic1 --value-format avro --from-beginning
Consume newly arriving non-Avro data from a topic called
mytopic2
on a development Kafka cluster on localhost:confluent consume mytopic2
Consume non-Avro data from the beginning of topic called
mytopic3
in Confluent Cloud (assumes you have initialized your Confluent Cloud configuration with Confluent Cloud CLI):confluent consume mytopic3 --cloud --from-beginning
Consume messages with keys and non-Avro values from the beginning of topic called
mytopic4
in Confluent Cloud, using a user-specified Confluent Cloud configuration file at/tmp/config
.confluent consume mytopic4 --cloud --config /tmp/config --from-beginning --property print.key=true
Consume Avro data from a topic called
mytopic5
in Confluent Cloud. Assumes Confluent Schema Registry is listening athttp://localhost:8081
.confluent consume mytopic5|dash| --cloud --value-format avro --from-beginning --property schema.registry.url=http://localhost:8081