bunny を使用して rabbitmq キューをセットアップしています。
namespace :rabbitmq do
desc 'Setup routing'
task :setup_test_commands_queue do
require 'bunny'
conn = Bunny.new(ENV['SYNC_AMQP'], read_timeout: 10, heartbeat: 10)
conn.start
ch = conn.create_channel
# get or create exchange
x = ch.direct('testsync.pcc', :persistent => true)
# get or create queue (note the durable setting)
queue = ch.queue('test.commmands', :durable => true, :ack => true, :routing_key => 'test_cmd')
# bind queue to exchange
queue.bind(x, :routing_key => 'test_cmd')
conn.close
end
end
上記のコードは、キューを作成し、ルーティング キー 'test_cmd' をバインドします。rabbitmq サーバーを再起動すると、キューは保持されますが、キューのバインディングが削除されます。
コマンドを使用しsudo invoke-rc.d rabbitmq-server restart
てrabbitmqを再起動しています。
Rabbit MQ バージョン: RabbitMQ 3.2.4、Erlang R16B03。
これはrabbitmqのデフォルトの動作ですか? キューのバインディングを永続化するにはどうすればよいですか?