Class: Hopper::Message::Delivered

Inherits:
Object
  • Object
show all
Defined in:
lib/hopper/message/delivered.rb

Defined Under Namespace

Classes: FatalError, RetryableError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, delivery_information, properties, payload) ⇒ Delivered

Returns a new instance of Delivered.


8
9
10
11
12
13
# File 'lib/hopper/message/delivered.rb', line 8

def initialize(queue, delivery_information, properties, payload)
  @queue = queue
  @delivery_information = delivery_information
  @properties = properties
  @message = Hopper::Message.new(payload)
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message


15
16
17
# File 'lib/hopper/message/delivered.rb', line 15

def message
  @message
end

Instance Method Details

#acknowledgeObject


21
22
23
24
# File 'lib/hopper/message/delivered.rb', line 21

def acknowledge  #Hopper.logger.info "Acknowledging #{tag}"

  @queue.acknowledge(self)
end

#reject(requeue = nil) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/hopper/message/delivered.rb', line 31

def reject(requeue = nil)
  if !requeue.nil?
    Hopper.logger.warn "Hopper::Queue::Message#reject with requeue set to 'true' is deprecated."
    if requeue
      self.retry
    else
      self.reject
    end
  else
    Hopper.logger.info "Rejecting #{tag}"
    @queue.reject(self)
  end
end

#retryObject


26
27
28
29
# File 'lib/hopper/message/delivered.rb', line 26

def retry
  Hopper.logger.info "Re-enqueueing #{tag}"
  @queue.retry(self)
end

#tagObject


49
50
51
# File 'lib/hopper/message/delivered.rb', line 49

def tag
  @delivery_information.delivery_tag
end

#terminateObject


45
46
47
# File 'lib/hopper/message/delivered.rb', line 45

def terminate
  @delivery_information.consumer.cancel
end