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

- old
+ new

@@ -9,11 +9,11 @@ def log(*args) p args end - # MQ.logging = true + # AMQP::Channel.logging = true if ARGV[0] == 'worker' log "prime checker #{Process.pid}", :started @@ -21,27 +21,27 @@ 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) EM.stop_event_loop if num == (MAX-1).to_s end } elsif ARGV[0] == 'controller' - 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) } 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 else # run n workers and 1 controller as an example