Class: ActiveMessaging::Adapters::Stomp::Message

Inherits:
BaseMessage
  • Object
show all
Defined in:
lib/activemessaging/adapters/stomp.rb

Instance Attribute Summary

Attributes inherited from BaseMessage

#body, #destination, #headers, #id

Instance Method Summary collapse

Methods inherited from BaseMessage

#dup, #to_s

Constructor Details

#initialize(msg) ⇒ Message

Returns a new instance of Message.



180
181
182
# File 'lib/activemessaging/adapters/stomp.rb', line 180

def initialize(msg)
  super(msg.body, msg.headers['message-id'], msg.headers, msg.headers['destination'])
end

Instance Method Details

#matches_subscription?(subscription) ⇒ Boolean

Returns:

  • (Boolean)


184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/activemessaging/adapters/stomp.rb', line 184

def matches_subscription?(subscription)
  # if the subscription has been specified in the headers, rely on this
  if self.headers['subscription'] && subscription.subscribe_headers['id']
    self.headers['subscription'].to_s == subscription.subscribe_headers['id'].to_s
    
  # see if the destination uses a wildcard representation
  elsif subscription.destination.wildcard
    self.destination.to_s =~ subscription.destination.wildcard
    
  # no subscription id? no wildcard? use the name of the destination as a straight match
  else
    self.destination.to_s == subscription.destination.value.to_s
  end
end