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, mercury_instance, work_queue_name: nil) ⇒ ReceivedMessage

Returns a new instance of ReceivedMessage.



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

def initialize(content, , mercury_instance, work_queue_name: nil)
  @content = content
  @metadata = 
  @mercury_instance = mercury_instance
  @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

#mercury_instanceObject (readonly)

Returns the value of attribute mercury_instance.



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

def mercury_instance
  @mercury_instance
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
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



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

def ack
  performing_action(:ack)
  .ack
end

#headersObject



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

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

#nackObject



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

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

#rejectObject



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

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

#republish(&k) ⇒ Object



39
40
41
42
# File 'lib/mercury/received_message.rb', line 39

def republish(&k)
  k ||= proc{}
  mercury_instance.republish(self, &k)
end

#republish_countObject



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

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

#tagObject



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

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