kcat

kcat as a Third-Party CLI Client

kcat (https://github.com/edenhill/kcat 5,784 ) (formerly kafkacat, BSD 2-clause) is a C binary on librdkafka, the library behind the Python, Go and .NET clients; it starts in milliseconds and formats output with a template. Its last release dates from 2021; Ubuntu 225 's 1.7.1 build prints a deprecation warning on every run, hidden here.

Reading with a format string and writing one key with two partitioners
# kcat from the host: a formatted read, then one key written with two partitioners
sudo apt-get install -y kcat >/dev/null 2>&1                 # Ubuntu's kcat 1.7.1
C="kcat -b localhost:33092"
$C -C -t booknest.order-events -p 0 -o -1 -e \
  -f 'partition %p offset %o key %k headers %h\n%s\n' 2>/dev/null
echo '{"customer_id":2948}' | $C -P -t booknest.customers -k 2948 2>/dev/null
echo '{"customer_id":2948}' | $C -P -t booknest.customers -k 2948 \
  -X partitioner=murmur2_random 2>/dev/null                # the Java client's hash
$C -C -t booknest.customers -e -q -f 'key %k -> partition %p\n' 2>/dev/null
Output
partition 0 offset 454 key 1001 headers source=web,trace=a1
{"type":"order_placed","order_id":1001}
key 2948 -> partition 1
key 2948 -> partition 4

-C consumes, -P produces, -L lists metadata, -o -1 starts at the last record, -e exits at the end. The writes expose a trap: librdkafka hashes keys with CRC32 by default, Java with murmur2, so kcat's default put customer 2948 in partition 4, while murmur2_random, like Kafka 129 's console producer, chose partition 1. Mixed clients on one keyed topic must all use murmur2 (Partitioners).