Class: BBK::AMQP::Message
- Inherits:
-
BBK::App::Dispatcher::Message
- Object
- BBK::App::Dispatcher::Message
- BBK::AMQP::Message
- Defined in:
- lib/bbk/amqp/message.rb
Overview
Store information about consumed AMQP message
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(consumer, delivery_info, properties, body) ⇒ Message
constructor
A new instance of Message.
-
#inspect ⇒ Object
:nodoc:.
- #message_id ⇒ Object
- #protocol ⇒ Object
- #reply_to ⇒ Object
- #user_id ⇒ Object
Constructor Details
#initialize(consumer, delivery_info, properties, body) ⇒ Message
Returns a new instance of Message.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bbk/amqp/message.rb', line 12 def initialize(consumer, delivery_info, properties, body) @properties = properties.to_h.with_indifferent_access headers = @properties.except(:headers).merge(@properties[:headers].presence || {}).with_indifferent_access amqp_consumer = delivery_info[:consumer] delivery_info = delivery_info.to_h.merge( message_consumer: consumer, protocols: consumer.protocols, queue: amqp_consumer&.queue_name ) super(consumer, delivery_info, headers, body) end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
10 11 12 |
# File 'lib/bbk/amqp/message.rb', line 10 def properties @properties end |
Instance Method Details
#clone ⇒ Object
38 39 40 |
# File 'lib/bbk/amqp/message.rb', line 38 def clone self.class.new(consumer, delivery_info, properties, body) end |
#inspect ⇒ Object
:nodoc:
46 47 48 |
# File 'lib/bbk/amqp/message.rb', line 46 def inspect # :nodoc: "#<#{self.class.name} @consumer=#{consumer.class.name}, @delivery_info=#{delivery_info.except(:message_consumer).inspect}, @headers=#{headers.inspect}, @properties=#{@properties.inspect}>" end |
#message_id ⇒ Object
26 27 28 |
# File 'lib/bbk/amqp/message.rb', line 26 def headers[:message_id] end |
#protocol ⇒ Object
42 43 44 |
# File 'lib/bbk/amqp/message.rb', line 42 def protocol consumer&.protocols&.first end |
#reply_to ⇒ Object
30 31 32 |
# File 'lib/bbk/amqp/message.rb', line 30 def reply_to headers[:reply_to] || user_id end |
#user_id ⇒ Object
34 35 36 |
# File 'lib/bbk/amqp/message.rb', line 34 def user_id headers[:user_id] end |