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 message
See the specific message types for details on how to access the data
portion of the message
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_correlation_id ⇒ Object
Returns the Message correlation ID as a String The resulting string may contain nulls.
-
#jms_correlation_id=(correlation_id) ⇒ Object
Set the Message correlation ID correlation_id: String Also supports embedded nulls within the correlation id.
-
#jms_delivery_mode ⇒ Object
Returns the JMS Delivery Mode One of the following will be returned JMS::DeliveryMode::PERSISTENT JMS::DeliveryMode::NON_PERSISTENT.
-
#jms_delivery_mode=(mode) ⇒ Object
Set the JMS Delivery Mode Values can be JMS::DeliveryMode::PERSISTENT JMS::DeliveryMode::NON_PERSISTENT.
-
#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.
-
#jms_destination ⇒ Object
Returns the Message Destination Instance of JMS::Destination.
-
#jms_destination=(destination) ⇒ Object
Set the Message Destination jms_destination: Must be an instance of JMS::Destination.
-
#jms_expiration ⇒ Object
Return the message expiration value as an Integer.
-
#jms_expiration=(expiration) ⇒ Object
Set the Message expiration value expiration: Integer.
-
#jms_message_id ⇒ Object
Returns the Message ID as a String The resulting string may contain embedded nulls.
-
#jms_message_id=(message_id) ⇒ Object
Set the Message correlation ID message_id: String Also supports nulls within the message id.
-
#jms_priority ⇒ Object
Returns the Message Priority level as an Integer.
-
#jms_priority=(priority) ⇒ Object
Set the Message priority level priority: Integer.
-
#jms_redelivered=(bool) ⇒ Object
Set whether the Message was redelivered bool: Boolean.
-
#jms_redelivered? ⇒ Boolean
Indicates whether the Message was redelivered?.
-
#jms_reply_to ⇒ Object
Returns the Message reply to Destination Instance of JMS::Destination.
-
#jms_reply_to=(reply_to) ⇒ Object
Set the Message reply to Destination reply_to: Must be an instance of JMS::Destination.
-
#jms_timestamp ⇒ Object
Returns the Message timestamp as Java Timestamp Integer TODO Return Ruby Time object?.
-
#jms_timestamp=(timestamp) ⇒ Object
Set the Message timestamp as Java Timestamp Integer timestamp: Must be an Java Timestamp Integer TODO Support Ruby Time.
-
#jms_type ⇒ Object
Returns the Message type supplied by the client when the message was sent.
-
#jms_type=(type) ⇒ Object
Sets the Message type type: String.
-
#persistent? ⇒ Boolean
Is the message 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
243 244 245 |
# File 'lib/jms/message.rb', line 243 def [](key) getObjectProperty key.to_s end |
#[]=(key, value) ⇒ Object
Set a property
248 249 250 |
# File 'lib/jms/message.rb', line 248 def []=(key, value) setObjectProperty(key.to_s, value) end |
#attributes ⇒ Object
Return the attributes (header fields) of the message as a Hash
225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/jms/message.rb', line 225 def attributes { :jms_correlation_id => jms_correlation_id, :jms_delivery_mode => jms_delivery_mode_sym, :jms_destination => jms_destination, :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?
253 254 255 256 |
# File 'lib/jms/message.rb', line 253 def include?(key) # Ensure a Ruby true is returned property_exists(key) == true end |
#inspect ⇒ Object
281 282 283 |
# File 'lib/jms/message.rb', line 281 def inspect "#{self.class.name}: #{data}\nAttributes: #{attributes.inspect}\nProperties: #{properties.inspect}" end |
#jms_correlation_id ⇒ Object
Returns the Message correlation ID as a String The resulting string may contain nulls
87 88 89 |
# File 'lib/jms/message.rb', line 87 def jms_correlation_id String.from_java_bytes(getJMSCorrelationIDAsBytes) if getJMSCorrelationIDAsBytes end |
#jms_correlation_id=(correlation_id) ⇒ Object
Set the Message correlation ID
correlation_id: String
Also supports embedded nulls within the correlation id
94 95 96 |
# File 'lib/jms/message.rb', line 94 def jms_correlation_id=(correlation_id) setJMSCorrelationIDAsBytes(correlation_id.nil? ? nil : correlation_id.to_java_bytes) end |
#jms_delivery_mode ⇒ Object
67 68 69 |
# File 'lib/jms/message.rb', line 67 def jms_delivery_mode getJMSDeliveryMode end |
#jms_delivery_mode=(mode) ⇒ Object
75 76 77 78 |
# File 'lib/jms/message.rb', line 75 def jms_delivery_mode=(mode) raise "Sorry, due to incompatibility with JRuby 1.6, please call jms_delivery_mode_sym when using symbols" if mode.is_a? Symbol self.setJMSDeliveryMode(mode) end |
#jms_delivery_mode_sym ⇒ Object
Return the JMS Delivery Mode as a Ruby symbol
:persistent
:non_persistent
nil if unknown
197 198 199 200 201 202 203 204 205 206 |
# File 'lib/jms/message.rb', line 197 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
212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/jms/message.rb', line 212 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 |
#jms_destination ⇒ Object
Returns the Message Destination
Instance of JMS::Destination
100 101 102 |
# File 'lib/jms/message.rb', line 100 def jms_destination getJMSDestination end |
#jms_destination=(destination) ⇒ Object
Set the Message Destination
jms_destination: Must be an instance of JMS::Destination
106 107 108 |
# File 'lib/jms/message.rb', line 106 def jms_destination=(destination) setJMSDestination(destination) end |
#jms_expiration ⇒ Object
Return the message expiration value as an Integer
111 112 113 |
# File 'lib/jms/message.rb', line 111 def jms_expiration getJMSExpiration end |
#jms_expiration=(expiration) ⇒ Object
Set the Message expiration value
expiration: Integer
117 118 119 |
# File 'lib/jms/message.rb', line 117 def jms_expiration=(expiration) setJMSExpiration(expiration) end |
#jms_message_id ⇒ Object
Returns the Message ID as a String The resulting string may contain embedded nulls
123 124 125 |
# File 'lib/jms/message.rb', line 123 def getJMSMessageID end |
#jms_message_id=(message_id) ⇒ Object
Set the Message correlation ID
message_id: String
Also supports nulls within the message id
130 131 132 |
# File 'lib/jms/message.rb', line 130 def () setJMSMessageID() end |
#jms_priority ⇒ Object
Returns the Message Priority level as an Integer
135 136 137 |
# File 'lib/jms/message.rb', line 135 def jms_priority getJMSPriority end |
#jms_priority=(priority) ⇒ Object
Set the Message priority level
priority: Integer
141 142 143 |
# File 'lib/jms/message.rb', line 141 def jms_priority=(priority) setJMSPriority(priority) end |
#jms_redelivered=(bool) ⇒ Object
Set whether the Message was redelivered
bool: Boolean
152 153 154 |
# File 'lib/jms/message.rb', line 152 def jms_redelivered=(bool) setJMSPriority(bool) end |
#jms_redelivered? ⇒ Boolean
Indicates whether the Message was redelivered?
146 147 148 |
# File 'lib/jms/message.rb', line 146 def jms_redelivered? getJMSRedelivered end |
#jms_reply_to ⇒ Object
Returns the Message reply to Destination
Instance of JMS::Destination
158 159 160 |
# File 'lib/jms/message.rb', line 158 def jms_reply_to getJMSReplyTo end |
#jms_reply_to=(reply_to) ⇒ Object
Set the Message reply to Destination
reply_to: Must be an instance of JMS::Destination
164 165 166 |
# File 'lib/jms/message.rb', line 164 def jms_reply_to=(reply_to) setJMSReplyTo(reply_to) end |
#jms_timestamp ⇒ Object
Returns the Message timestamp as Java Timestamp Integer TODO Return Ruby Time object?
170 171 172 |
# File 'lib/jms/message.rb', line 170 def getJMSTimestamp end |
#jms_timestamp=(timestamp) ⇒ Object
Set the Message timestamp as Java Timestamp Integer
timestamp: Must be an Java Timestamp Integer
TODO Support Ruby Time
177 178 179 |
# File 'lib/jms/message.rb', line 177 def () setJMSTimestamp() end |
#jms_type ⇒ Object
Returns the Message type supplied by the client when the message was sent
182 183 184 |
# File 'lib/jms/message.rb', line 182 def jms_type getJMSType end |
#jms_type=(type) ⇒ Object
Sets the Message type
type: String
188 189 190 |
# File 'lib/jms/message.rb', line 188 def jms_type=(type) setJMSType(type) end |
#persistent? ⇒ Boolean
Is the message persistent?
81 82 83 |
# File 'lib/jms/message.rb', line 81 def persistent? getJMSDeliveryMode == JMS::DeliveryMode::PERSISTENT end |
#properties ⇒ Object
Return Properties as a hash
259 260 261 262 263 |
# File 'lib/jms/message.rb', line 259 def properties h = {} properties_each_pair {|k,v| h[k]=v} h end |
#properties=(h) ⇒ Object
Set Properties from an existing hash
266 267 268 269 270 |
# File 'lib/jms/message.rb', line 266 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
273 274 275 276 277 278 279 |
# File 'lib/jms/message.rb', line 273 def properties_each_pair(&proc) enum = getPropertyNames while enum.has_more_elements key = enum.next_element proc.call key, getObjectProperty(key) end end |