desc "Create RabbitMQ exchanges"
task setup_exchange: :environment do
  config = YAML.load_file(Rails.root.join("config/rabbitmq.yml"))[Rails.env].symbolize_keys

  bunny = Bunny.new(ENV["RABBITMQ_URL"])
  channel = bunny.start.create_channel
  Bunny::Exchange.new(channel, :topic, config[:exchange])
end

desc "Create RabbitMQ exchanges"
task setup_exchange: :environment do
  config = Rails.application.config_for(:rabbitmq)

  bunny = Bunny.new(ENV["RABBITMQ_URL"])
  channel = bunny.start.create_channel
  Bunny::Exchange.new(channel, :topic, config[:exchange])
end

Use Rails method to get RabbitMQ config
Use Rails method to get RabbitMQ config

The previous implementation isn't compatible with Ruby 3.1 due to the
upgrade of Psych (YAML library) to 4.0 [1] in stdlib and the change in `load_file`.

A simpler way to replace this is to use the Rails built in method to
load a config file.

[1]: https://github.com/ruby/psych/pull/488
