mirror of https://github.com/reiseburo/hermann
Add example scripts testing producer and consumer functionality.
This commit is contained in:
parent
3081848bde
commit
8aff9226b7
|
@ -0,0 +1,13 @@
|
|||
require 'hermann'
|
||||
|
||||
c = Hermann::Consumer.new( "lms_messages", "localhost:9092", 0 )
|
||||
t1 = 0
|
||||
c.consume() do
|
||||
|msg| puts("Received: #{msg}")
|
||||
if(t1 == 0)
|
||||
t1 = Time.now
|
||||
end
|
||||
t2 = Time.now
|
||||
elapsed = t2 - t1
|
||||
puts("Total elapsed time: #{elapsed} seconds")
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
require 'hermann'
|
||||
p = Hermann::Producer.new("lms_messages", "localhost:9092")
|
||||
arr = (0..1000000).to_a.map { |x| "message_#{x}"}
|
||||
t1 = Time.now
|
||||
arr.each { |x| p.push(x) }
|
||||
t2 = Time.now
|
||||
elapsed = t2 - t1
|
||||
puts "Done!"
|
||||
puts "Total elapsed time: #{elapsed} seconds"
|
||||
sleep 30
|
|
@ -0,0 +1,13 @@
|
|||
# Produce messages for a given amount of time
|
||||
|
||||
require 'rubygems'
|
||||
require 'hermann'
|
||||
|
||||
stopTime = Time.now + 60 # One minute from now
|
||||
p = Hermann::Producer.new("lms_messages")
|
||||
count = 0
|
||||
while(Time.now < stopTime)
|
||||
p.push("Message_#{count}")
|
||||
count = count + 1
|
||||
end
|
||||
puts("Done!")
|
Loading…
Reference in New Issue