0
我嘗試這種代碼(從網上的文章在這裏了:http://www.randomhacks.net/articles/2009/05/08/chat-client-ruby-amqp-eventmachine-shoes)紅寶石AMQP未初始化的恆定誤差
require 'rubygems' gem 'amqp' require 'mq' unless ARGV.length == 2 STDERR.puts "Usage: #{$0} " exit 1 end $channel, $nick = ARGV AMQP.start(:host => 'localhost') do $chat = MQ.topic('chat') # Print any messages on our channel. queue = MQ.queue($nick) queue.bind('chat', :key => $channel) queue.subscribe do |msg| if msg.index("#{$nick}:") != 0 puts msg end end # Forward console input to our channel. module KeyboardInput include EM::Protocols::LineText2 def receive_line data $chat.publish("#{$nick}: #{data}", :routing_key => $channel) end end EM.open_keyboard(KeyboardInput) end
,但最終出現以下錯誤:
chat.rb:11:in `': uninitialized constant AMQP (NameError)
在那之後,我試着不同的示例代碼與我的開發環境中的AMQP,但都顯示我的錯誤。所以問題不在代碼中,我的開發環境問題。任何人都可以用我的開發環境指出我的問題。提前致謝。
嗨,我要重新安裝它。我在Centos 5.4 – sparrow 2010-05-28 09:57:44
祝你好運,並在這裏後,如果你卡住 – 2010-05-28 10:03:11
我得到同樣的錯誤在Ubuntu(精確)。任何運氣修復這個? – Poul 2013-12-17 03:06:00