class Msgr::Message
Attributes
delivery_info[R]
metadata[R]
payload[R]
route[R]
Public Class Methods
new(channel, delivery_info, metadata, payload, route)
click to toggle source
# File lib/msgr/message.rb, line 7 def initialize(channel, delivery_info, metadata, payload, route) @channel = channel @delivery_info = delivery_info @metadata = metadata @payload = payload @route = route if content_type == 'application/json' # rubocop:disable Style/GuardClause @payload = JSON.parse(payload) @payload.symbolize_keys! if @payload.respond_to? :symbolize_keys! end end
Public Instance Methods
ack()
click to toggle source
Send message acknowledge to broker unless message is already acknowledged.
@api public
# File lib/msgr/message.rb, line 38 def ack return if acked? @acked = true @channel.ack delivery_info.delivery_tag end
acked?()
click to toggle source
Check if message is already acknowledged.
@return [Boolean] True if message is acknowledged, false otherwise. @api public
# File lib/msgr/message.rb, line 29 def acked? @acked ? true : false end
content_type()
click to toggle source
# File lib/msgr/message.rb, line 20 def content_type @metadata.content_type end
nack()
click to toggle source
Send negative message acknowledge to broker unless message is already acknowledged.
@api public
# File lib/msgr/message.rb, line 50 def nack return if acked? @acked = true @channel.nack delivery_info.delivery_tag end