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.



189
190
191
# File 'lib/activemessaging/adapters/stomp.rb', line 189

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)


193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/activemessaging/adapters/stomp.rb', line 193

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