を読んだとき、私は私がserviseにウサギを実装し、テストしてみましたUbuntu14.04、レール5、RabbitMQの(サーバー3.6.5)、バニー2.5.1RabbitMQのタイムアウト::エラー:IOタイムアウト7バイト
を使用それ。
私は次のRubyスクリプトを書いた:
Mq::RabbitService
サービスは、それがキューなどに、私はそれが良い作品スタートを
Mq::RabbitService.new('test_queue').subscribe
を実行する他の端末を
を作成し、バニー、接続を初期化などが
def rabbit_test
s_time = Time.current
10_000.times do |n|
Mq::RabbitService.new('test_queue').publish(n.to_s)
end
p "###############################"
p "RabbirMQ Diff: #{Time.current - s_time}"
p "###############################"
end
しかし、私は827メッセージだけをプッシュすることができます(なぜ私は正確に837がわかりませんが、常に同じ番号です)。
は私の出版社の昇給エラーその後:
[8] pry(main)> rabbit_test
E, [2016-08-19T15:17:02.445820 #6409] ERROR -- #<Bunny::Session:0x6fb39858 [email protected]:5672, vhost=/, addresses=[192.168.1.67:5672]>: Got an exception when receiving data: IO timeout when reading 7 bytes (Timeout::Error)
Timeout::Error: IO timeout when reading 7 bytes
from /home/oleg/.rvm/gems/ruby-2.3.1/gems/bunny-2.5.1/lib/bunny/cruby/socket.rb:52:in `rescue in read_fully'
はまた、私が試した:管理者権限を持つ新しいユーザーを追加し、同じ結果(192.168.0.11
のような)localhost
アドレスに代わりにIPを追加してみました。
EDITEDが
私はRabbitMQの接続Mq::RabbitService gist
しかし
def rabbit_test
s_time = Time.current
1_000.times do |n|
connection = Bunny.new(host: '192.168.1.67', port: 5672, user: 'oleg', password: '111111').start
channel = connection.create_channel
channel.queue('queue_name', auto_delete: true)
exchange = channel.default_exchange
exchange.publish(n.to_s, routing_key: 'queue_name')
channel.close
end
p "###############################"
p "RabbirMQ Diff: #{Time.current - s_time}"
p "###############################"
end
のための私のサービスを使用するには、たぶん誰かが私が間違って何をすべきかを知って、あまりにも
動作しませんか?
ありがとうございました
あなた自身で 'Mq :: RabbitService'を作成しましたか、それとも宝石ですか?自分のクラスであれば、このクラスに要点をリンクできますか? – slowjack2k
EDITEDマークの後で問題を確認できます –
ループ外に接続を移動できますか?問題と関係があるのかどうかはわかりませんが、毎回新しい接続を作成するのはなぜですか? – theMayer