Module: JMS::Message
- Defined in:
- lib/jms/message.rb
Overview
Extend JMS Message Interface with Ruby methods
A Message is the item that can be put on a queue, or obtained from a queue.
A Message consists of 3 major parts:
- Header
Accessible as attributes of the Message class
- Properties
Accessible via [] and []= methods
- Data
The actual data portion of the
See the specific types for details on how to access the data
portion of the
For further help on javax.jms.Message
http://download.oracle.com/javaee/6/api/index.html?javax/jms/Message.html
Interface javax.jms.Message
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get the value of a property.
-
#[]=(key, value) ⇒ Object
Set a property.
-
#attributes ⇒ Object
Return the attributes (header fields) of the message as a Hash.
-
#include?(key) ⇒ Boolean
Does message include specified property?.
- #inspect ⇒ Object
-
#jms_delivery_mode_sym ⇒ Object
Return the JMS Delivery Mode as a Ruby symbol :persistent :non_persistent nil if unknown.
-
#jms_delivery_mode_sym=(mode) ⇒ Object
Set the JMS Delivery Mode from a Ruby Symbol Valid values for mode :persistent :non_persistent.
-
#properties ⇒ Object
Return Properties as a hash.
-
#properties=(h) ⇒ Object
Set Properties from an existing hash.
-
#properties_each_pair(&proc) ⇒ Object
Return each name value pair.
Instance Method Details
#[](key) ⇒ Object
Get the value of a property
92 93 94 |
# File 'lib/jms/message.rb', line 92 def [](key) getObjectProperty key.to_s end |
#[]=(key, value) ⇒ Object
Set a property
97 98 99 |
# File 'lib/jms/message.rb', line 97 def []=(key, value) setObjectProperty(key.to_s, value) end |
#attributes ⇒ Object
Return the attributes (header fields) of the message as a Hash
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/jms/message.rb', line 74 def attributes { jms_correlation_id: jms_correlation_id, jms_delivery_mode_sym: jms_delivery_mode_sym, jms_destination: jms_destination.nil? ? nil : jms_destination.to_string, jms_expiration: jms_expiration, jms_message_id: , jms_priority: jms_priority, jms_redelivered: jms_redelivered?, jms_reply_to: jms_reply_to, jms_timestamp: , jms_type: jms_type, } end |
#include?(key) ⇒ Boolean
Does message include specified property?
102 103 104 105 |
# File 'lib/jms/message.rb', line 102 def include?(key) # Ensure a Ruby true is returned property_exists(key) == true end |
#inspect ⇒ Object
130 131 132 |
# File 'lib/jms/message.rb', line 130 def inspect "#{self.class.name}: #{data}\nAttributes: #{attributes.inspect}\nProperties: #{properties.inspect}" end |
#jms_delivery_mode_sym ⇒ Object
Return the JMS Delivery Mode as a Ruby symbol
:persistent
:non_persistent
nil if unknown
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/jms/message.rb', line 45 def jms_delivery_mode_sym case jms_delivery_mode when JMS::DeliveryMode::PERSISTENT :persistent when JMS::DeliveryMode::NON_PERSISTENT :non_persistent else nil end end |
#jms_delivery_mode_sym=(mode) ⇒ Object
Set the JMS Delivery Mode from a Ruby Symbol Valid values for mode
:persistent
:non_persistent
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/jms/message.rb', line 60 def jms_delivery_mode_sym=(mode) val = case mode when :persistent JMS::DeliveryMode::PERSISTENT when :non_persistent JMS::DeliveryMode::NON_PERSISTENT else raise "Unknown delivery mode symbol: #{mode}" end self.setJMSDeliveryMode(val) end |
#properties ⇒ Object
Return Properties as a hash
108 109 110 111 112 |
# File 'lib/jms/message.rb', line 108 def properties h = {} properties_each_pair { |k, v| h[k]=v } h end |
#properties=(h) ⇒ Object
Set Properties from an existing hash
115 116 117 118 119 |
# File 'lib/jms/message.rb', line 115 def properties=(h) clear_properties h.each_pair { |k, v| setObjectProperty(k.to_s, v) } h end |
#properties_each_pair(&proc) ⇒ Object
Return each name value pair
122 123 124 125 126 127 128 |
# File 'lib/jms/message.rb', line 122 def properties_each_pair(&proc) enum = getPropertyNames while enum.has_more_elements key = enum.next_element proc.call key, getObjectProperty(key) end end |