Created
February 20, 2019 07:14
-
-
Save himangSharatun/0eb21d54928939a004aa114a8309623c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RabbitQueueService | |
def self.logger | |
Rails.logger.tagged('bunny') do | |
@@_logger ||= Rails.logger | |
end | |
end | |
def self.connection | |
@@_connection ||= begin | |
instance = Bunny.new( | |
addresses: ENV['BUNNY_AMQP_ADDRESSES'].split(','), | |
username: ENV['BUNNY_AMQP_USER'], | |
password: ENV['BUNNY_AMQP_PASSWORD'], | |
vhost: ENV['BUNNY_AMQP_VHOST'], | |
automatically_recover: true, | |
connection_timeout: 2, | |
continuation_timeout: (ENV['BUNNY_CONTINUATION_TIMEOUT'] || 10_000).to_i, | |
logger: RabbitQueueService.logger | |
) | |
instance.start | |
instance | |
end | |
end | |
ObjectSpace.define_finalizer(RailsMessageQueue::Application, proc { puts "Closing rabbitmq connections"; RabbitQueueService.connection&.close }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is showing this error in rails 5.2
/config/initializers/rabbitmq_initializer.rb:25:in '<class:RabbitQueueService>': uninitialized constant RabbitQueueService::RailsMessageQueue (NameError)