Module: Sidekiq::Sqs::Fetcher
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/sidekiq-sqs/fetcher.rb
Constant Summary collapse
- QueueNotDoneError =
Class.new(StandardError)
Instance Method Summary collapse
- #fetch ⇒ Object
- #fetch_single_message(queue) ⇒ Object
- #initialize_with_sqs(mgr, queues, strict) ⇒ Object
Instance Method Details
#fetch ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sidekiq-sqs/fetcher.rb', line 21 def fetch watchdog('Fetcher#fetch died') do return if Sidekiq::Fetcher.done? begin queue = nil msg = nil ## FIXME queues = queues_cmd queues.pop # Last entry is TIMEOUT msg = queues.inject(nil) do |, queue| || (queue) end if msg @mgr.assign!(msg, File.basename(msg.queue.url)) else after(5) { fetch } end rescue QueueNotDoneError # Just wait after(5) { fetch } rescue => ex logger.error("Error fetching message from queues (#{@queues.join(', ')}): #{ex}") logger.error(ex.backtrace.first) sleep(self.class::TIMEOUT) after(0) { fetch } end end end |
#fetch_single_message(queue) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sidekiq-sqs/fetcher.rb', line 54 def (queue) queue = Sidekiq.sqs.queues.named(queue) = queue. if @strictly_ordered_queues && .nil? # If messages being processed, raise if queue. != 0 raise QueueNotDoneError end else end end |
#initialize_with_sqs(mgr, queues, strict) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sidekiq-sqs/fetcher.rb', line 13 def initialize_with_sqs(mgr, queues, strict) initialize_without_sqs(mgr, queues, strict) # Fix Queue names @queues = @queues.map {|queue| Sidekiq::Client.environmental_queue_name queue.gsub(/^queue:/, '') } @unique_queues = @queues.uniq end |