class ActiveMessaging::Adapters::Amqp::AmqpMessage

Attributes

command[R]
delivery_tag[RW]
destination[RW]

Public Class Methods

new(data, queue_name = nil) click to toggle source
Calls superclass method
# 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

Public Instance Methods

headers() click to toggle source
Calls superclass method
# File lib/activemessaging/adapters/amqp.rb, line 192
def headers
  super.merge({
    :destination  => routing_key,
    :delivery_tag => @delivery_tag
  })
end
matches_subscription?(subscription) click to toggle source
# 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