confluent consume

Description

Consume data from topics. By default this command consumes non-Avro data from the 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.
--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:

    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):

    # manually specify Confluent Cloud bootstrap-server value (substitute your server)
    confluent consume mytopic3 --consumer.config ~/.ccloud/config --bootstrap-server r0.domain.confluent.cloud:9092 --from-beginning
    
    # dynamically determine Confluent Cloud bootstrap-server value
    confluent consume mytopic3 --consumer.config ~/.ccloud/config --bootstrap-server $(grep bootstrap.server ~/.ccloud/config | awk -F'=' '{print $2;}') --from-beginning