Class: MQ::Queue

Inherits:
Object show all
Defined in:
lib/nanite/amqp.rb

Instance Method Summary collapse

Constructor Details

#initialize(mq, name, opts = {}) ⇒ Queue

Monkey patch to add :no_declare => true for new queue objects. See the explanation for MQ::Exchange#initialize below.



6
7
8
9
10
11
12
13
14
15
# File 'lib/nanite/amqp.rb', line 6

def initialize mq, name, opts = {}
  @mq = mq
  @opts = opts
  @bindings ||= {}
  @mq.queues[@name = name] ||= self
  @mq.callback{
  @mq.send Protocol::Queue::Declare.new({ :queue => name,
                                          :nowait => true }.merge(opts))
  } unless opts[:no_declare]
end

Instance Method Details

#recover(requeue = false) ⇒ Object

Asks the broker to redeliver all unacknowledged messages on a specifieid channel. Zero or more messages may be redelivered.

  • requeue (default false)

If this parameter is false, the message will be redelivered to the original recipient. If this flag is true, the server will attempt to requeue the message, potentially then delivering it to an alternative subscriber.



24
25
26
27
28
29
# File 'lib/nanite/amqp.rb', line 24

def recover requeue = false
  @mq.callback{
    @mq.send Protocol::Basic::Recover.new({ :requeue => requeue })
  }
  self
end