research/primes-forked.rb in amqp-0.7.0 vs research/primes-forked.rb in amqp-0.7.1

- old
+ new

@@ -21,11 +21,11 @@ def log(*args) p args end -# MQ.logging = true +# AMQP::Channel.logging = true # worker workers = ARGV[0] ? (Integer(ARGV[0]) rescue 2) : 2 @@ -37,29 +37,29 @@ def prime? ('1' * self) !~ /^1?$|^(11+?)\1+$/ end end - MQ.queue('prime checker').subscribe { |info, num| + AMQP::Channel.queue('prime checker').subscribe { |info, num| log "prime checker #{Process.pid}", :prime?, num if Integer(num).prime? - MQ.queue(info.reply_to).publish(num, :reply_to => Process.pid) + AMQP::Channel.queue(info.reply_to).publish(num, :reply_to => Process.pid) end } } end # controller EM.run { - MQ.queue('prime collector').subscribe { |info, prime| + AMQP::Channel.queue('prime collector').subscribe { |info, prime| log 'prime collector', :received, prime, :from, info.reply_to (@primes ||= []) << Integer(prime) EM.stop_event_loop if prime == '499' } MAX.times do |i| EM.next_tick do - MQ.queue('prime checker').publish((i+1).to_s, :reply_to => 'prime collector') + AMQP::Channel.queue('prime checker').publish((i+1).to_s, :reply_to => 'prime collector') end end }