Kafka Console is a command-line interface (CLI) tool designed for interacting with Apache Kafka clusters. It simplifies common Kafka operations such as listing topics, consuming messages from specific topics and partitions, and producing messages to topics. The current stable version is 3.1.13. As a CLI tool, its release cadence is generally driven by feature additions, bug fixes, and compatibility with newer Kafka broker versions. Key differentiators include robust support for various SASL authentication mechanisms (plain, scram-sha-256, scram-sha-512, oauthbearer) and TLS/SSL connections, making it suitable for secure Kafka environments. It offers flexible message consumption options like consuming from specific offsets or timestamps, filtering, and outputting in JSONL or raw formats. For production, it supports static headers and reading messages from stdin or a file, making it versatile for scripting and automation. It directly addresses the need for a capable, easy-to-use, yet powerful terminal-based Kafka client.
npm install kafka-consoleNo compatibility data collected yet for this library.
This quickstart demonstrates how to programmatically execute `kafka-console` commands using Node.js's `child_process` module to list topics, produce, and consume messages.
Double-check broker security configurations and corresponding `kafka-console` options. Consider environment variables like `KAFKA_MECHANISM`, `KAFKA_USERNAME`, etc., for sensitive credentials.
For non-JSON message values, always explicitly set `--data-format raw`. For custom formats, provide a path to a custom formatter script.
Use `--from 0` to ensure all historical messages are considered. For new messages only, rely on the default or specify a timestamp. Always consider the impact of `--group` on offset management.
For continuous or large-scale consumption, always specify a unique `--group` name to leverage Kafka's offset management and avoid redundant processing across restarts or multiple consumers.
Verify the broker address (e.g., `localhost:9092`), ensure the Kafka broker process is active, and check any local or network firewall configurations. Confirm the port is correct.
Verify the topic name using `kafka-console list`. If the topic exists, check Kafka ACLs or security configurations to ensure the user has consume/produce permissions.
Double-check the `--username`, `--password`, `--mechanism`, or `--oauth-bearer` options against your Kafka broker's SASL setup. Ensure the mechanism is supported by both client and broker.
If messages are not JSON, use `--data-format raw` to consume them as raw strings or buffers. If they are intended to be JSON, inspect the message content for malformed JSON.
No dependency data recorded yet.