Class: Tackle::Consumer::Message
- Inherits:
-
Object
- Object
- Tackle::Consumer::Message
- Defined in:
- lib/tackle/consumer/message.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #ack ⇒ Object
- #delivery_tag ⇒ Object
-
#initialize(connection, logger, delivery_info, properties, payload) ⇒ Message
constructor
A new instance of Message.
- #log_error(message) ⇒ Object
- #log_info(message) ⇒ Object
- #nack ⇒ Object
- #retry_count ⇒ Object
Constructor Details
#initialize(connection, logger, delivery_info, properties, payload) ⇒ Message
Returns a new instance of Message.
9 10 11 12 13 14 15 16 |
# File 'lib/tackle/consumer/message.rb', line 9 def initialize(connection, logger, delivery_info, properties, payload) @connection = connection @logger = logger @delivery_info = delivery_info @properties = properties @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
5 6 7 |
# File 'lib/tackle/consumer/message.rb', line 5 def payload @payload end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
6 7 8 |
# File 'lib/tackle/consumer/message.rb', line 6 def properties @properties end |
Instance Method Details
#ack ⇒ Object
18 19 20 21 22 |
# File 'lib/tackle/consumer/message.rb', line 18 def ack log_info "Sending positive acknowledgement to source queue" @connection.channel.ack(delivery_tag) log_info "Positive acknowledgement sent" end |
#delivery_tag ⇒ Object
38 39 40 |
# File 'lib/tackle/consumer/message.rb', line 38 def delivery_tag @delivery_info.delivery_tag end |
#log_error(message) ⇒ Object
46 47 48 |
# File 'lib/tackle/consumer/message.rb', line 46 def log_error() @logger.error("[delivery_tag=#{delivery_tag}] #{}") end |
#log_info(message) ⇒ Object
42 43 44 |
# File 'lib/tackle/consumer/message.rb', line 42 def log_info() @logger.info("[delivery_tag=#{delivery_tag}] #{}") end |
#nack ⇒ Object
24 25 26 27 28 |
# File 'lib/tackle/consumer/message.rb', line 24 def nack log_error "Sending negative acknowledgement to source queue" @connection.channel.nack(delivery_tag) log_error "Negative acknowledgement sent" end |
#retry_count ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/tackle/consumer/message.rb', line 30 def retry_count if @properties.headers && @properties.headers["retry_count"] @properties.headers["retry_count"] else 0 end end |