1

所以我需要能够为每个 Sidekiq 线程创建一个 RabbitMQ 连接和通道,因为如果我不这样做,我会用完 RabbitMQ 连接,因为文档建议这样做。文档展示了如何使用Unicorn进行操作:

before_fork do |server, worker|
  $rabbitmq_connection.close if $rabbitmq_connection
end

after_fork do |server, worker|
  # the following is *required* for Rails + "preload_app true",
  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection

    $rabbitmq_connection = Bunny.new
    $rabbitmq_connection.start

    $rabbitmq_channel    = $rabbitmq_connection.create_channel
  end
end

是否可以为 Sidekiq 线程做类似的事情?有什么我可以做的Sidekiq.server_configure吗?看起来是 Sidekiq 启动线程的地方,但我无论如何都看不到要挂接到启动/停止?

4

1 回答 1

2

创建您自己的 RabbitMQ 连接池,详细信息如下:

https://github.com/mperham/sidekiq/wiki/Advanced-Options#connection-pooling

于 2015-01-10T06:33:22.623 回答