Class: Backstage::Message
Constant Summary
collapse
- IGNORED_PROPERTIES =
[ 'JMSXDeliveryCount', TorqueBox::Messaging::Message::ENCODING_PROPERTY ]
- JMS_PROPERTIES =
%w{ JMS_Correlation_ID JMS_Priority JMS_Type JMS_Reply_To JMS_Redelivered }
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Resource
#association_chain, #available_actions, included, #resource, #to_hash
Constructor Details
#initialize(message) ⇒ Message
Returns a new instance of Message.
23
24
25
|
# File 'lib/destinations/models/message.rb', line 23
def initialize(message)
@torquebox_message = message
end
|
Class Method Details
.to_hash_attributes ⇒ Object
66
67
68
|
# File 'lib/destinations/models/message.rb', line 66
def self.to_hash_attributes
super + [:jms_id, :delivery_count, :properties, :content]
end
|
Instance Method Details
31
32
33
34
35
36
37
38
39
|
# File 'lib/destinations/models/message.rb', line 31
def content
@torquebox_message.decode.inspect
rescue Exception => ex
if @jms_message.respond_to?(:text)
@jms_message.text
else
"Undecodable message"
end
end
|
#delivery_count ⇒ Object
62
63
64
|
# File 'lib/destinations/models/message.rb', line 62
def delivery_count
jms_message.get_string_property( 'JMSXDeliveryCount' )
end
|
#jms_id ⇒ Object
Also known as:
full_name
41
42
43
|
# File 'lib/destinations/models/message.rb', line 41
def jms_id
jms_message.jms_message_id
end
|
#jms_message ⇒ Object
27
28
29
|
# File 'lib/destinations/models/message.rb', line 27
def jms_message
@torquebox_message.jms_message
end
|
#jms_properties ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/destinations/models/message.rb', line 54
def jms_properties
@jms_properties ||= JMS_PROPERTIES.inject( {} ) do |props,name|
value = jms_message.send(name.downcase)
props[name.gsub('_',' ')] = value.to_s if value props
end
end
|
#properties ⇒ Object
46
47
48
49
50
51
|
# File 'lib/destinations/models/message.rb', line 46
def properties
@properties ||= jms_message.property_names.inject( {} ) do |properties, name|
properties[name] = jms_message.get_string_property( name ) unless IGNORED_PROPERTIES.include?( name )
properties
end
end
|