Class: ActiveMessaging::Adapters::Amqp::AmqpMessage
- Inherits:
-
Emissary::Message
- Object
- Emissary::Message
- ActiveMessaging::Adapters::Amqp::AmqpMessage
- Defined in:
- lib/activemessaging/adapters/amqp.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#delivery_tag ⇒ Object
Returns the value of attribute delivery_tag.
-
#destination ⇒ Object
Returns the value of attribute destination.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(data, queue_name = nil) ⇒ AmqpMessage
constructor
A new instance of AmqpMessage.
- #matches_subscription?(subscription) ⇒ Boolean
Constructor Details
#initialize(data, queue_name = nil) ⇒ AmqpMessage
Returns a new instance of AmqpMessage.
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/activemessaging/adapters/amqp.rb', line 179 def initialize(data, queue_name = nil) data[:data] = data.delete(:body) unless (data[:data] && !data[:body]) super(data) @delivery_tag ||= (data[:headers][:delivery_tag] rescue nil) @destination ||= (data[:headers][:destination] rescue nil) || queue_name || routing_key @command = "MESSAGE" end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
176 177 178 |
# File 'lib/activemessaging/adapters/amqp.rb', line 176 def command @command end |
#delivery_tag ⇒ Object
Returns the value of attribute delivery_tag.
177 178 179 |
# File 'lib/activemessaging/adapters/amqp.rb', line 177 def delivery_tag @delivery_tag end |
#destination ⇒ Object
Returns the value of attribute destination.
177 178 179 |
# File 'lib/activemessaging/adapters/amqp.rb', line 177 def destination @destination end |
Instance Method Details
#headers ⇒ Object
192 193 194 195 196 197 |
# File 'lib/activemessaging/adapters/amqp.rb', line 192 def headers super.merge({ :destination => routing_key, :delivery_tag => @delivery_tag }) end |
#matches_subscription?(subscription) ⇒ Boolean
199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/activemessaging/adapters/amqp.rb', line 199 def matches_subscription?(subscription) # use routing key first, otherwise, use the defined destination value destination = subscription.subscribe_headers[:routing_key] || subscription.destination.value.to_s if destination.match(/(\#|\*)/) dest_regex = ::Regexp.new(destination.gsub('.*', '[.][^.]+').gsub(/\.\#.*/, '[.].*')) !!(headers[:destination].to_s =~ dest_regex) else !!(headers[:destination].to_s == destination) end end |