ruby-kafka is a Ruby gem for producing and consuming Kafka messages, focused on operational simplicity with logging and metrics. Maintenance has shifted to rdkafka-ruby.
Overview
ruby-kafka connects Ruby applications to Apache Kafka clusters. A client is initialized with seed brokers and discovers the rest of the cluster, keeping its own broker connection pool for a single thread.
Producers can send single messages or buffer batches with retries and delivery guarantees. An asynchronous producer API avoids blocking the caller by delivering in a background thread, with optional buffer-size and interval policies. Consumers support groups, checkpointing, subscriptions, and batch reads.
Message keys and values are treated as binary data so teams pick their own serialization, such as JSON or Avro. Partitioning can spread load or pin related events to one partition via partition or message keys. SSL and SASL security options are documented.
The maintainers state the library is no longer actively developed and recommend librdkafka via rdkafka-ruby for production, though security and bug fixes may still appear. Kafka broker version support varies by gem release series, with fuller coverage on older broker lines and limited support on newer Kafka versions.
Key features
- Cluster discovery from seed brokers
- Sync and async producers
- Consumer groups and checkpointing
- Configurable partitioning keys
- SSL and SASL authentication
- Instrumentation and metrics hooks
- Topic management helpers
- Buffering with retry handling
Use cases
- Ruby apps publishing to Kafka
- Ruby consumers in consumer groups
- Rails apps streaming events
- Legacy Kafka 0.9–0.10 integrations