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.



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

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



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

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



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

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