class Mercury::ReceivedMessage
Attributes
action_taken[R]
content[R]
mercury_instance[R]
metadata[R]
work_queue_name[R]
Public Class Methods
new(content, metadata, mercury_instance, work_queue_name: nil)
click to toggle source
# File lib/mercury/received_message.rb, line 5 def initialize(content, metadata, mercury_instance, work_queue_name: nil) @content = content @metadata = metadata @mercury_instance = mercury_instance @work_queue_name = work_queue_name end
Public Instance Methods
ack()
click to toggle source
# File lib/mercury/received_message.rb, line 24 def ack performing_action(:ack) metadata.ack end
headers()
click to toggle source
# File lib/mercury/received_message.rb, line 16 def headers (metadata.headers || {}).dup end
nack()
click to toggle source
# File lib/mercury/received_message.rb, line 34 def nack performing_action(:nack) metadata.reject(requeue: true) end
reject()
click to toggle source
# File lib/mercury/received_message.rb, line 29 def reject performing_action(:reject) metadata.reject(requeue: false) end
republish(&k)
click to toggle source
# File lib/mercury/received_message.rb, line 39 def republish(&k) k ||= proc{} mercury_instance.republish(self, &k) end
republish_count()
click to toggle source
# File lib/mercury/received_message.rb, line 20 def republish_count (metadata.headers[Mercury::REPUBLISH_COUNT_HEADER] || 0).to_i end
tag()
click to toggle source
# File lib/mercury/received_message.rb, line 12 def tag headers[Mercury::ORIGINAL_TAG_HEADER] || metadata.routing_key end
Private Instance Methods
is_ackable()
click to toggle source
# File lib/mercury/received_message.rb, line 46 def is_ackable @work_queue_name != nil end
performing_action(action)
click to toggle source
# File lib/mercury/received_message.rb, line 50 def performing_action(action) is_ackable or raise "This message is not #{action}able" if @action_taken raise "This message was already #{@action_taken}ed" end @action_taken = action end