.. _confluent_local_consume: ================= 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 :ref:`configure ` the ``PATH`` environment variable to point to the |cp| ``bin`` directory. For reference on how to use Confluent CLI to produce to a topic, see :ref:`confluent produce `. Usage ----- .. codewithvars:: bash confluent consume |dash| [--value-format avro] [other optional args] .. tip:: For usage information, enter ``confluent help consume``. Required Arguments ------------------ =================================== ======= ============================================== Name, shorthand Default Description =================================== ======= ============================================== ```` Kafka topic to consume messages from =================================== ======= ============================================== Optional Arguments ------------------ Here are some common optional arguments. For a full list of optional arguments: .. codewithvars:: bash confluent help consume =========================== ================== ===================================================== Name, shorthand Default Description =========================== ================== ===================================================== ``--value-format avro`` Specify the topic data as Avro data. ``--cloud`` Connect to |ccloud| using configuration file at default location ``$HOME/.ccloud/config`` ``--config `` 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 |sr-long| is listening at ``http://localhost:8081``. .. codewithvars:: bash confluent consume mytopic1|dash| --value-format avro --from-beginning - Consume newly arriving non-Avro data from a topic called ``mytopic2`` on a development Kafka cluster on localhost: .. codewithvars:: bash confluent consume mytopic2 - Consume non-Avro data from the beginning of topic called ``mytopic3`` in |ccloud| (assumes you have initialized your |ccloud| configuration with `Confluent Cloud CLI `__): .. codewithvars:: bash confluent consume mytopic3|dash| --cloud --from-beginning - Consume messages with keys and non-Avro values from the beginning of topic called ``mytopic4`` in |ccloud|, using a user-specified |ccloud| configuration file at ``/tmp/config``. .. codewithvars:: bash confluent consume mytopic4|dash| --cloud --config /tmp/config --from-beginning --property print.key=true - Consume Avro data from a topic called ``mytopic5`` in |ccloud|. Assumes |sr-long| is listening at ``http://localhost:8081``. .. sourcecode:: bash confluent consume mytopic5|dash| --cloud --value-format avro --from-beginning --property schema.registry.url=http://localhost:8081