gitmyhub

kcat

C ★ 5.8k updated 2y ago

Generic command line non-JVM Apache Kafka producer and consumer

kcat is a lightweight command-line tool for sending and reading messages on Apache Kafka from your terminal without needing Java, a single small binary handles producing, consuming, and inspecting a Kafka cluster.

ClibrdkafkaDockersetup: easycomplexity 2/5

kcat (previously named kafkacat) is a command-line tool for working with Apache Kafka, the distributed messaging system used to pass data between applications. The tool is written in C and does not require the Java runtime that most official Kafka tooling depends on, which makes it much smaller and faster to start up. The statically linked binary is under 150 kilobytes.

Apache Kafka organizes data into named topics, and each topic is split into partitions. Messages flow from producers (things that write data) to consumers (things that read data). kcat lets you do both directly from the terminal, making it useful for debugging, testing pipelines, or piping data in and out of Kafka without writing any code.

In producer mode, kcat reads lines from standard input and sends each one as a message to a topic you specify. You can also read from files, set compression, add headers, produce transactions, and enable exactly-once delivery guarantees. In consumer mode, kcat reads messages from a topic and prints them to standard output. You can subscribe to multiple topics at once, join a consumer group for balanced reading across instances, seek to specific offsets or timestamps, and control the output format. There is also a metadata mode that prints a summary of the entire Kafka cluster, including all brokers, topics, and partitions.

The tool supports Avro message decoding through the Confluent Schema Registry, and it can deserialize keys or values using custom primitive format strings. Any Kafka configuration setting can be passed on the command line or stored in a config file, including SSL and SASL authentication settings for secure clusters.

kcat is available via apt on Debian systems, Homebrew on macOS, dnf on Fedora, and as a Docker image. It can also be built from source using a bootstrap script that downloads and compiles its dependencies automatically.

Where it fits