update README.md with new consumer info

This commit is contained in:
Ben Osheroff 2015-04-27 09:37:53 -07:00
parent 3792ee206b
commit 18c73f3f82
1 changed files with 24 additions and 4 deletions

View File

@ -59,18 +59,16 @@ f.state
Messages can be consumed by calling the consume method and passing a block to handle the yielded messages. The consume method blocks, so take care to handle that functionality appropriately (i.e. use Concurrent::Promise, Thread, etc).
#### (JRuby-only)
#### (JRuby)
```ruby
require 'hermann'
require 'hermann/consumer'
require 'hermann_jars'
zookeepers = "localhost:2181"
groupId = "group1"
topic = 'topic'
new_topic = 'other_topic'
the_consumer = Hermann::Consumer.new(topic, groupId, zookeepers)
the_consumer = Hermann::Consumer.new(topic, zookeepers: "localhost:2181", group_id: "group1")
the_consumer.consume(new_topic) do |msg| # can change topic with optional argument to .consume
puts "Recv: #{msg}"
@ -78,6 +76,28 @@ end
```
#### (MRI)
MRI currently has no zookeeper / client group support.
```ruby
require 'hermann'
require 'hermann/consumer'
topic = 'topic'
new_topic = 'other_topic'
the_consumer = Hermann::Consumer.new(topic, brokers: "localhost:9092", partition: 1)
the_consumer.consume(new_topic) do |msg| # can change topic with optional argument to .consume
puts "Recv: #{msg}"
end
```
#### How to convert from using jruby-kafka