0.0
No commit activity in last 3 years
No release in over 3 years
A high level Kafka client that supports producer, low level consumers, and high level consumers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
~> 5.6
~> 1.1
~> 0.10
~> 10.0

Runtime

~> 1.9
 Project Readme

KafkaSyrup

KafkaSyrup is a Kafka client compatible with the Kafka 0.8 API and above.

Installation

Add this line to your application's Gemfile:

gem 'kafka_syrup'

And then execute:

$ bundle

Or install it yourself as:

$ gem install kafka-syrup

Usage

Configuration

require 'kafka_syrup'

KafkaSyrup.configure do |config|
  config.brokers = 'localhost:9092,localhost:9093,localhost:9094'

  # For consuming in a group
  config.zookeeper_hosts = 'localhost:2181'
end

Additional configuration options can be found in the main kafka_syrup.rb file

Sending messages to Kafka

producer = KafkaSyrup::Producer.new(topic: :foo)

producer.send_message('hello world')

Consuming messages from a single Kafka partition

consumer = KafkaSyrup::PartitionConsumer.new(topic: :foo, partition: 1)

consumer.fetch

# It is possible to limit the number of messages returned:
consumer.fetch(50)

Note that regardless of the limit, fetch() will block until it has received at least one message.

Consuming messages in a group

consumer = KafkaSyrup::TopicConsumer.new(topic: :foo, group: :bar)

consumer.fetch

# It is possible to limit the number of messages returned:
consumer.fetch(50)

Note that regardless of the limit, fetch() will block until it has received at least one message.

The topic consumer utilizes zookeeper for coordination with other members of the group and is fully compatible with the normal Kafka high level consumer. (ie - kafk_syrup clients and java kafka clients can coexist in the same group with no problem.)