Created
September 1, 2015 03:52
-
-
Save film42/165927748c893776fd2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start = nil | |
NATS.start(:servers => ['nats://198.199.103.139:4222']) do | |
start = Time.now | |
NATS.subscribe('demo', :queue => 'group.things') do |msg, reply| | |
puts "Hitting node 1 with #{msg}" | |
NATS.publish(reply, "Polo1!") | |
end | |
NATS.subscribe('demo', :queue => 'group.things') do |msg, reply| | |
puts "Hitting node 2 with #{msg}" | |
NATS.publish(reply, "Polo2!") | |
end | |
NATS.subscribe('demo', :queue => 'group.things') do |msg, reply| | |
puts "Hitting node 3 with #{msg}" | |
NATS.publish(reply, "Polo3!") | |
end | |
1000.times do |i| | |
NATS.request('demo', "Marcko... #{i}") do |response| | |
puts "Req #{i} done" | |
if i == 999 | |
duration = Time.now - start | |
puts "Duration: #{duration * 1000} ms" | |
NATS.stop | |
end | |
end | |
end | |
end | |
# Duration: 244.68 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment