Sha256: 81e78deb4d57294c40426e445d07c0320019a1cb5c612cb4cce3442e75b0445b
Contents?: true
Size: 828 Bytes
Versions: 6
Compression:
Stored size: 828 Bytes
Contents
require 'mq' # Monkey patching some methods into AMQP to make it more testable module AMQP # Initializes new AMQP client/connection without starting another EM loop def self.start_connection(opts={}, &block) # puts "!!!!!!!!! Existing connection: #{@conn}" if @conn @conn = connect opts @conn.callback(&block) if block end # Closes AMQP connection gracefully def self.stop_connection if AMQP.conn and not AMQP.closing # MQ.reset ? @closing = true @conn.close { yield if block_given? cleanup_state } end end # Cleans up AMQP state after AMQP connection closes def self.cleanup_state # MQ.reset ? Thread.list.each { |thread| thread[:mq] = nil } Thread.list.each { |thread| thread[:mq_id] = nil } @conn = nil @closing = false end end
Version data entries
6 entries across 6 versions & 1 rubygems