module BBQueue class Producer attr_accessor :queue_name, :logger, :stalking def initialize(queue_name, options = {}) self.queue_name = queue_name self.logger = options[:logger] || BBQueue::NullLogger.new self.stalking = Stalking::Producer.new(options.merge(:logger => BBQueue::FatalLogger.new(logger))) end def enqueue(object, options = {}) logger.info "Enqueue #{object.inspect} with #{options.inspect} on #{queue_name.inspect}" obj = BBQueue::Serializer.dump(object) unless stalking.enqueue(queue_name, { "object" => obj }, options) logger.error "Enqueue #{obj.inspect} with #{options.inspect} on #{queue_name.inspect} failed" return false end true end end end