lib/mq/rpc.rb in amqp-0.5.3 vs lib/mq/rpc.rb in amqp-0.5.5

- old
+ new

@@ -22,19 +22,21 @@ @mq.queue(info.reply_to).publish(::Marshal.dump(ret), :key => info.reply_to, :message_id => info.message_id) end } else @callbacks ||= {} - @queue = @mq.queue(@name = 'some random identifier for me').subscribe{|info, msg| + # XXX implement and use queue(nil) + @queue = @mq.queue(@name = "random identifier #{::Kernel.rand(999_999_999_999)}").subscribe{|info, msg| if blk = @callbacks.delete(info.message_id) blk.call ::Marshal.load(msg) end } @remote = @mq.queue(queue) end end def method_missing meth, *args, &blk + # XXX use uuids instead message_id = "random message id #{::Kernel.rand(999_999_999_999)}" @callbacks[message_id] = blk if blk @remote.publish(::Marshal.dump([meth, *args]), :reply_to => blk ? @name : nil, :message_id => message_id) end end \ No newline at end of file