Skip to content
Repo containing jruby projects wrapping kafka jars
Ruby
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.gitignore
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
VERSION
kafka-jar.gemspec

README.md

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
You can’t perform that action at this time.