Skip to content

Commit

Permalink
Merge pull request #4025 from bgeuken/rabbitmq_fix
Browse files Browse the repository at this point in the history
[frontend] Fix crash when configuring exchange options for RabbitMQ
  • Loading branch information
Moisés Déniz Alemán committed Oct 17, 2017
2 parents ffee0b1 + 475816c commit b74a8ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/api/lib/rabbitmq_bus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ def self.publish(event_queue_name, event_payload)
return unless CONFIG['amqp_options']
start_connection

queue = $rabbitmq_channel.queue(event_queue_name, CONFIG['amqp_queue_options'].try(:with_indifferent_access) || {})
queue = $rabbitmq_channel.queue(event_queue_name, CONFIG['amqp_queue_options'].try(:symbolize_keys) || {})
$rabbitmq_exchange.publish(event_payload, routing_key: queue.name)
end

# Start one connection, channel and exchange per rails process
# and reuse them
def self.start_connection
$rabbitmq_conn ||= Bunny.new(CONFIG['amqp_options'].with_indifferent_access)
$rabbitmq_conn ||= Bunny.new(CONFIG['amqp_options'].try(:symbolize_keys))
$rabbitmq_conn.start
$rabbitmq_channel ||= $rabbitmq_conn.create_channel
$rabbitmq_exchange = if CONFIG['amqp_exchange_name']
$rabbitmq_channel.exchange(CONFIG['amqp_exchange_name'], CONFIG['amqp_exchange_options'].try(:with_indifferent_access) || {})
$rabbitmq_channel.exchange(CONFIG['amqp_exchange_name'], CONFIG['amqp_exchange_options'].try(:symbolize_keys) || {})
else
$rabbitmq_channel.default_exchange
end
Expand Down

0 comments on commit b74a8ac

Please sign in to comment.