Sha256: cabab6e9a93c1a25ea9f8d1c8d3bcf0ed0dcb789b7692f4eb53045b742c5ccef
Contents?: true
Size: 809 Bytes
Versions: 2
Compression:
Stored size: 809 Bytes
Contents
require 'bunny' require 'connection_pool' require 'woodhouse/dispatchers/common_amqp_dispatcher' class Woodhouse::Dispatchers::BunnyDispatcher < Woodhouse::Dispatchers::CommonAmqpDispatcher def initialize(config) super @pool = new_pool end private def publish_job(job, exchange) exchange.publish(job.payload, :headers => job.arguments) end def run retried = false @pool.with do |conn| yield conn end rescue Bunny::ClientTimeout if retried raise else new_pool! retried = true retry end end private def new_pool! @pool = new_pool end def new_pool @bunny.stop if @bunny bunny = @bunny = Bunny.new(@config.server_info || {}) @bunny.start ConnectionPool.new { bunny.create_channel } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
woodhouse-0.1.2 | lib/woodhouse/dispatchers/bunny_dispatcher.rb |
woodhouse-0.1.1 | lib/woodhouse/dispatchers/bunny_dispatcher.rb |