examples/pingpong.rb in amqp-0.5.0 vs examples/pingpong.rb in amqp-0.5.1
- old
+ new
@@ -8,46 +8,38 @@
end
# AMQP.logging = true
amq = MQ.new
- amq.queue('one').subscribe{ |headers, msg|
- log 'one', :received, msg, :from => headers.reply_to
+ EM.add_periodic_timer(1){
+ puts
- if headers.reply_to
- msg[1] = 'o'
+ log :sending, 'ping'
+ amq.queue('one').publish('ping')
+ }
- log 'one', :sending, msg, :to => headers.reply_to
- amq.direct.publish(msg, :key => headers.reply_to)
- else
- puts
- end
+ amq = MQ.new
+ amq.queue('one').subscribe{ |msg|
+ log 'one', :received, msg, :sending, 'pong'
+ amq.queue('two').publish('pong')
}
amq = MQ.new
amq.queue('two').subscribe{ |msg|
log 'two', :received, msg
- puts
}
- amq = MQ.new
- amq.direct.publish('ding', :key => 'one')
- EM.add_periodic_timer(1){
- log :sending, 'ping', :to => 'one', :from => 'two'
- amq.direct.publish('ping', :key => 'one', :reply_to => 'two')
- }
-
}
__END__
-[Thu Jul 17 21:23:55 -0700 2008, "one", :received, "ding", {:from=>nil}]
+[Sun Jul 20 03:52:24 -0700 2008, :sending, "ping"]
+[Sun Jul 20 03:52:24 -0700 2008, "one", :received, "ping", :sending, "pong"]
+[Sun Jul 20 03:52:24 -0700 2008, "two", :received, "pong"]
-[Thu Jul 17 21:23:56 -0700 2008, :sending, "ping", {:from=>"two", :to=>"one"}]
-[Thu Jul 17 21:23:56 -0700 2008, "one", :received, "ping", {:from=>"two"}]
-[Thu Jul 17 21:23:56 -0700 2008, "one", :sending, "pong", {:to=>"two"}]
-[Thu Jul 17 21:23:56 -0700 2008, "two", :received, "pong"]
+[Sun Jul 20 03:52:25 -0700 2008, :sending, "ping"]
+[Sun Jul 20 03:52:25 -0700 2008, "one", :received, "ping", :sending, "pong"]
+[Sun Jul 20 03:52:25 -0700 2008, "two", :received, "pong"]
-[Thu Jul 17 21:23:57 -0700 2008, :sending, "ping", {:from=>"two", :to=>"one"}]
-[Thu Jul 17 21:23:57 -0700 2008, "one", :received, "ping", {:from=>"two"}]
-[Thu Jul 17 21:23:57 -0700 2008, "one", :sending, "pong", {:to=>"two"}]
-[Thu Jul 17 21:23:57 -0700 2008, "two", :received, "pong"]
\ No newline at end of file
+[Sun Jul 20 03:52:26 -0700 2008, :sending, "ping"]
+[Sun Jul 20 03:52:26 -0700 2008, "one", :received, "ping", :sending, "pong"]
+[Sun Jul 20 03:52:26 -0700 2008, "two", :received, "pong"]