Class: Droid::BackwardsCompatibleQueue

Inherits:
BaseQueue
  • Object
show all
Defined in:
lib/droid/queue.rb

Instance Attribute Summary

Attributes inherited from BaseQueue

#ex, #mq, #opts, #q, #queue_name

Instance Method Summary collapse

Methods inherited from BaseQueue

#destroy, #log, #tag, #teardown, #temp?

Constructor Details

#initialize(exchange_name, opts = {}) ⇒ BackwardsCompatibleQueue

Returns a new instance of BackwardsCompatibleQueue.



146
147
148
149
150
151
# File 'lib/droid/queue.rb', line 146

def initialize(exchange_name, opts={})
  opts[:auto_delete] = true unless opts.has_key?(:auto_delete) and opts[:auto_delete] === false
  opts[:exchange_name] = exchange_name
  queue_name = opts.delete(:queue) || Droid::Utils.generate_queue(exchange_name)
  @queue_name, @opts = queue_name, opts
end

Instance Method Details

#setupObject



153
154
155
156
157
158
159
# File 'lib/droid/queue.rb', line 153

def setup
  @mq = MQ.new
  @q = @mq.queue(queue_name, opts)
  @ex = @mq.direct(opts[:exchange_name])

  @mq.prefetch(opts[:prefetch]) if opts[:prefetch]
end

#subscribe(amqp_opts = {}, opts = {}) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/droid/queue.rb', line 161

def subscribe(amqp_opts={}, opts={})
  super(amqp_opts, opts) do |request|
    if block_given?
      if opts[:detail]
        yield request, request.header, request.raw_message if block_given?
      else
        yield request if block_given?
      end
    end
  end

  self
end