All Projects → appsignal → Rdkafka Ruby

appsignal / Rdkafka Ruby

Licence: mit
Modern and performant Kafka client library for Ruby based on librdkafka

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Rdkafka Ruby

Kafka Rest
Confluent REST Proxy for Kafka
Stars: ✭ 1,863 (+1125.66%)
Mutual labels:  kafka
Technology Talk
汇总java生态圈常用技术框架、开源中间件,系统架构、数据库、大公司架构案例、常用三方类库、项目管理、线上问题排查、个人成长、思考等知识
Stars: ✭ 12,136 (+7884.21%)
Mutual labels:  kafka
Kafka Eagle
A easy and high-performance monitoring system, for comprehensive monitoring and management of kafka cluster.
Stars: ✭ 2,240 (+1373.68%)
Mutual labels:  kafka
Azure Event Hubs Spark
Enabling Continuous Data Processing with Apache Spark and Azure Event Hubs
Stars: ✭ 140 (-7.89%)
Mutual labels:  kafka
Kafka Tutorials
Kafka Tutorials microsite
Stars: ✭ 144 (-5.26%)
Mutual labels:  kafka
Kafkajs
A modern Apache Kafka client for node.js
Stars: ✭ 2,315 (+1423.03%)
Mutual labels:  kafka
Syslog Gollector
Syslog Collector written in Go, streams to Kafka 0.8
Stars: ✭ 138 (-9.21%)
Mutual labels:  kafka
Akhq
Kafka GUI for Apache Kafka to manage topics, topics data, consumers group, schema registry, connect and more...
Stars: ✭ 2,195 (+1344.08%)
Mutual labels:  kafka
Awesome Kafka
Everything about Apache Kafka
Stars: ✭ 144 (-5.26%)
Mutual labels:  kafka
Kcli
A kafka command line browser
Stars: ✭ 148 (-2.63%)
Mutual labels:  kafka
My Moments
Instagram Clone - Cloning Instagram for learning purpose
Stars: ✭ 140 (-7.89%)
Mutual labels:  kafka
Oryx
Oryx 2: Lambda architecture on Apache Spark, Apache Kafka for real-time large scale machine learning
Stars: ✭ 1,785 (+1074.34%)
Mutual labels:  kafka
Azkarra Streams
🚀 Azkarra is a lightweight java framework to make it easy to develop, deploy and manage cloud-native streaming microservices based on Apache Kafka Streams.
Stars: ✭ 146 (-3.95%)
Mutual labels:  kafka
Eel Sdk
Big Data Toolkit for the JVM
Stars: ✭ 140 (-7.89%)
Mutual labels:  kafka
Phpkafka
PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.
Stars: ✭ 149 (-1.97%)
Mutual labels:  kafka
Kafka Docker Playground
Playground for Kafka/Confluent Docker experimentations
Stars: ✭ 140 (-7.89%)
Mutual labels:  kafka
Supersafebank
Sample Event Sourcing implementation with .NET Core
Stars: ✭ 142 (-6.58%)
Mutual labels:  kafka
Streamline
StreamLine - Streaming Analytics
Stars: ✭ 151 (-0.66%)
Mutual labels:  kafka
Netty Learning Example
🥚 Netty实践学习案例,见微知著!带着你的心,跟着教程。我相信你行欧。
Stars: ✭ 2,146 (+1311.84%)
Mutual labels:  kafka
A Kafka Story
Kafka ecosystem ... but step by step!
Stars: ✭ 148 (-2.63%)
Mutual labels:  kafka

Rdkafka

Build Status Gem Version Maintainability

The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka. It wraps the production-ready C client using the ffi gem and targets Kafka 1.0+ and Ruby 2.4+.

rdkafka was written because we needed a reliable Ruby client for Kafka that supports modern Kafka at AppSignal. We run it in production on very high traffic systems.

This gem only provides a high-level Kafka consumer. If you are running an older version of Kafka and/or need the legacy simple consumer we suggest using the Hermann gem.

The most important pieces of a Kafka client are implemented. We're working towards feature completeness, you can track that here: https://github.com/appsignal/rdkafka-ruby/milestone/1

Installation

This gem downloads and compiles librdkafka when it is installed. If you have any problems installing the gem please open an issue.

Usage

See the documentation for full details on how to use this gem. Two quick examples:

Consuming messages

Subscribe to a topic and get messages. Kafka will automatically spread the available partitions over consumers with the same group id.

config = {
  :"bootstrap.servers" => "localhost:9092",
  :"group.id" => "ruby-test"
}
consumer = Rdkafka::Config.new(config).consumer
consumer.subscribe("ruby-test-topic")

consumer.each do |message|
  puts "Message received: #{message}"
end

Producing messages

Produce a number of messages, put the delivery handles in an array and wait for them before exiting. This way the messages will be batched and sent to Kafka in an efficient way.

config = {:"bootstrap.servers" => "localhost:9092"}
producer = Rdkafka::Config.new(config).producer
delivery_handles = []

100.times do |i|
  puts "Producing message #{i}"
  delivery_handles << producer.produce(
      topic:   "ruby-test-topic",
      payload: "Payload #{i}",
      key:     "Key #{i}"
  )
end

delivery_handles.each(&:wait)

Note that creating a producer consumes some resources that will not be released until it #close is explicitly called, so be sure to call Config#producer only as necessary.

Development

A Docker Compose file is included to run Kafka and Zookeeper. To run that:

docker-compose up

Run bundle and cd ext && bundle exec rake && cd .. to download and compile librdkafka.

You can then run bundle exec rspec to run the tests. To see rdkafka debug output:

DEBUG_PRODUCER=true bundle exec rspec
DEBUG_CONSUMER=true bundle exec rspec

After running the tests you can bring the cluster down to start with a clean slate:

docker-compose down

Example

To see everything working run these in separate tabs:

bundle exec rake consume_messages
bundle exec rake produce_messages
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].