kfc producer [--brokers=<brks>] [--partition=<part>] [--compression=<comp>]
[--delimiter=<delim>] [--key-delimiter=<delim>] [--count=<cnt>]
[--error-file=<file>] [-T | --tee] [-q | --quiet]
[ (-X <conf>)... ] [-v | --verbose] <topic> [<file>...]
kfc consumer [--brokers=<brks>] [--partition=<part>] [--offset=<off>]
[--delimiter=<delim>] [--key-delimiter=<delim>] [--count=<cnt>]
[-e | --exit] [-O | --print-offset] [-u | --unbuffered]
[ (-X <conf>)... ] [-q | --quiet] [-v | --verbose] <topic>
kfc metadata [--brokers=<brks>] [--partition=<part>] [-q | --quiet]
[ (-X <conf>)... ] [-v | --verbose] [<topic>]
kfc --help
kfc --version
kfc
also known as kafkacat
is a generic non-JVM producer and consumer for
Apache Kafka 0.8, think of it as a netcat for Kafka.
kfc
works in different : producer, consumer and metadata. Each one
is described in the [COMMAND] section.
-
producer
reads messages from stdin, delimited with a configurable delimeter and produces them to the provided Kafka cluster, topic and partition. -
consumer
reads messages from a topic (and possibly a specific partition ) and prints them to stdout using the configured message delimiter. -
metadata
displays the current state of the Kafka cluster and its topics and partitions.
-
-b <brokers>, --brokers=<brokers>
Comma separated list of broker(s) to bootstrap the connection, e.g. "host1:9292,host2:9293" [default: localhost]. -
-p <partition>, --partition=<partition>
Send messages to a specific partition. If -1 is provided, a random partition is attributed to each message. -
-X <conf>
Relay<conf>
to librdkafka configuration system. This option hides a lot of functionnality. For more information, the user should read the matchingCONFIGURATION.md
of librdkafka. -
-v, --verbose
Augment verbosity level. -
-q, --quiet
Quiet mode, do not report error messages to stderr. -
-V, --version
Show the version on the first line and follow with the usage and help message. -
-h, --help
Show the usage and help message.
-
-d <delim>, --delimiter=<delim>
Message delimiter character: a-z.. | \r | \n | \t | \xNN [default: \n]. -
-k <delim>, --key-delimiter=<delim>
Key delimiter character: a-z.. | \r | \n | \t | \xNN. -
-c <cnt>, --count=<cnt>
Exit after producing<cnt>
messages. -
-z <c>, --compression=<c>
Compression applied to messages: none, snappy or gzip [default: none]. -
-T, --tee
Output queued messages to stdout, acting like tee. A message is relayed to stdout once it hits librdkafka's internal queue, it can still fail to reach the broker. See-E
for more information on failed messages. -
-E <file>, --error-file=<file>
Messages that couldn't be sent are written to<file>
. There is no guarantee on the ordering of messages [default: stderr].
-
-d <delim>, --delimiter=<delim>
Message delimiter character: a-z.. | \r | \n | \t | \xNN [default: \n]. -
-k <delim>, --key-delimiter=<delim>
Key delimiter character: a-z.. | \r | \n | \t | \xNN. -
-o <off>, --offset=<off>
Define the consuming offset, the possible values are:beginning
: start from the beginningend
: start from the endstored
: start from a stored value<value>
: start at absolute-<value>
: start at relative offset from the end (acting liketail
).
-
-c <cnt>, --count=<cnt>
Exit after consuming<cnt>
messages. -
-e , --exit
Exit when there is no message left to consumer in the topic. -
-u , --unbuffered
Do not buffer stdout, useful for low volume topic.
- Producing a single message
$ echo "test message" | kfc producer test
- Consuming the last message and exiting immediately
$ kfc consumer -e -o -1 test
test message
- Showing metadata on the test topic
$ kfc metadata test
{
"brokers": [
{ "id":0, "host":"localhost:9092" }
],
"topics": [
{
"name": "test",
"partitions": [
{ "id": 0, "leader": 0, "replicas": [0], "isrs": [0] }
]
}
]
}