Skip to content

Instantly share code, notes, and snippets.

@film42
Created September 1, 2015 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save film42/165927748c893776fd2b to your computer and use it in GitHub Desktop.
Save film42/165927748c893776fd2b to your computer and use it in GitHub Desktop.
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