mirror of https://github.com/reiseburo/hermann
update README.md with new consumer info
This commit is contained in:
parent
3792ee206b
commit
18c73f3f82
28
README.md
28
README.md
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue