Class: Mercury::ReceivedMessage
- Inherits:
-
Object
- Object
- Mercury::ReceivedMessage
- Defined in:
- lib/mercury/received_message.rb
Instance Attribute Summary collapse
-
#action_taken ⇒ Object
readonly
Returns the value of attribute action_taken.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#mercury_instance ⇒ Object
readonly
Returns the value of attribute mercury_instance.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#work_queue_name ⇒ Object
readonly
Returns the value of attribute work_queue_name.
Instance Method Summary collapse
- #ack ⇒ Object
- #headers ⇒ Object
-
#initialize(content, metadata, mercury_instance, work_queue_name: nil) ⇒ ReceivedMessage
constructor
A new instance of ReceivedMessage.
- #nack ⇒ Object
- #reject ⇒ Object
- #republish(&k) ⇒ Object
- #republish_count ⇒ Object
- #tag ⇒ Object
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_taken ⇒ Object (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 |
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/mercury/received_message.rb', line 3 def content @content end |
#mercury_instance ⇒ Object (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 |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/mercury/received_message.rb', line 3 def @metadata end |
#work_queue_name ⇒ Object (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
#ack ⇒ Object
24 25 26 27 |
# File 'lib/mercury/received_message.rb', line 24 def ack performing_action(:ack) .ack end |
#headers ⇒ Object
16 17 18 |
# File 'lib/mercury/received_message.rb', line 16 def headers (.headers || {}).dup end |
#nack ⇒ Object
34 35 36 37 |
# File 'lib/mercury/received_message.rb', line 34 def nack performing_action(:nack) .reject(requeue: true) end |
#reject ⇒ Object
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_count ⇒ Object
20 21 22 |
# File 'lib/mercury/received_message.rb', line 20 def republish_count (.headers[Mercury::REPUBLISH_COUNT_HEADER] || 0).to_i end |
#tag ⇒ Object
12 13 14 |
# File 'lib/mercury/received_message.rb', line 12 def tag headers[Mercury::ORIGINAL_TAG_HEADER] || .routing_key end |