Class: Mercury::ReceivedMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/mercury/received_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, metadata, work_queue_name: nil) ⇒ ReceivedMessage

Returns a new instance of ReceivedMessage.



5
6
7
8
9
# File 'lib/mercury/received_message.rb', line 5

def initialize(content, , work_queue_name: nil)
  @content = content
   = 
  @work_queue_name = work_queue_name
end

Instance Attribute Details

#action_takenObject (readonly)

Returns the value of attribute action_taken.



3
4
5
# File 'lib/mercury/received_message.rb', line 3

def action_taken
  @action_taken
end

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/mercury/received_message.rb', line 3

def content
  @content
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3
4
5
# File 'lib/mercury/received_message.rb', line 3

def 
  
end

#work_queue_nameObject (readonly)

Returns the value of attribute work_queue_name.



3
4
5
# File 'lib/mercury/received_message.rb', line 3

def work_queue_name
  @work_queue_name
end

Instance Method Details

#ackObject



23
24
25
26
# File 'lib/mercury/received_message.rb', line 23

def ack
  performing_action(:ack)
  .ack
end

#headersObject



15
16
17
# File 'lib/mercury/received_message.rb', line 15

def headers
  (.headers || {}).dup
end

#nackObject



33
34
35
36
# File 'lib/mercury/received_message.rb', line 33

def nack
  performing_action(:nack)
  .reject(requeue: true)
end

#rejectObject



28
29
30
31
# File 'lib/mercury/received_message.rb', line 28

def reject
  performing_action(:reject)
  .reject(requeue: false)
end

#republish_countObject



19
20
21
# File 'lib/mercury/received_message.rb', line 19

def republish_count
  (.headers[Mercury::REPUBLISH_COUNT_HEADER] || 0).to_i
end

#tagObject



11
12
13
# File 'lib/mercury/received_message.rb', line 11

def tag
  headers[Mercury::ORIGINAL_TAG_HEADER] || .routing_key
end