Project

kafka-jar

0.0
No commit activity in last 3 years
No release in over 3 years
A Jruby Gem that loads the Kafka library jar
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 10.5
~> 3.1.0
 Project Readme

kafka-jar-gems

Travis Build Status

Repo containing jruby projects wrapping the Kafka jar

Install

require 'kafka-jar', '~> 0.8.2.2'

Example: Starting Up Kafka Server

java_import "java.util.Properties"                                                                                      
java_import "kafka.server.KafkaConfig"
java_import "kafka.server.KafkaServerStartable"
java_import "org.apache.kafka.clients.producer.KafkaProducer"
java_import "org.apache.kafka.clients.producer.ProducerRecord"
java_import "org.apache.zookeeper.server.ServerConfig"
java_import "org.apache.zookeeper.server.ZooKeeperServerMain"
java_import "org.apache.zookeeper.server.quorum.QuorumPeerConfig"

zk_props = Properties.new
zk_props.set_property("dataDir", "/tmp/zookeeper")
zk_props.set_property("clientPort", "2181")
zk = ZooKeeperServerMain.new
quorum_configuration = QuorumPeerConfig.new
quorum_configuration.parse_properties(zk_props)
config = ServerConfig.new
config.read_from(quorum_configuration)
Thread.new do
  zk.run_from_config(config)
end

kafka_props = Properties.new
kafka_props.set_property("zookeeper.connect", "localhost:2181")
kafka_props.set_property("broker.id", "0")
kafka_config = KafkaConfig.new(kafka_props)
@server = KafkaServerStartable.new(kafka_config)
@server.startup