我有一个 ruby 进程,它使用 amqp gem 消耗来自 RabbitMQ 队列的消息,如下所示:
require "bundler/setup"
require "amqp"
require 'eventmachine'
require 'em-http'
AMQP.start(:host => $AMQP_URL) do |connection|
@channel ||= AMQP::Channel.new(connection)
@queue ||= @channel.queue("results")
puts " [*] Waiting for messages. "
@queue.subscribe do |body|
http = EventMachine::HttpRequest.new(URL).post :body => body
http.callback {
# do something
}
http.errback {
$LOG.error "[errorback] -> #{http.error}"
}
end
end
现在 URL 很慢,并且队列有很多消息(> 30K),我在日志中收到了这个错误:
**[errorback] -> unable to create new socket: Too many open files**
任何帮助都将受到高度赞赏,因为我一直在尝试找出如何解决它但根本没有结果。
提前致谢