Class Qpid::Messaging::Message
In: lib/qpid_messaging/message.rb
Parent: Object

A Message represents an routable piece of information.

The content for a message is automatically encoded and decoded.

Methods

Public Class methods

Creates a new instance of Message.

Options

Examples

  message = Qpid::Messaging::Message.new :content => "This is a message."

Public Instance methods

Returns the value for the named property.

Options

  • name - the property name

Examples

  # use of message properties to mark a message as digitally signed
  verify(msg) if msg[:signed]

Assigns a value to the named property.

*NOTE:* Both the key or the value may be a symbol, but they will both be converted to a String for ease of transport.

Options

  • name - the property name
  • value - the property value

Returns the content of the Message.

Content is automatically decoded based on the specified content type. If the content type is application-specific, then no decoding is performed and the content is returnedas a String representation.

For example, if an array of integers are sent, then the receiver will find the message content to be an array of String objects, where each String is a representation of the sent integer value.

Sets the content for the Message.

Content is automatically encoded for Array and Hash types. Other types need to set their own content types (via content_type) in order to specify how recipients should process the content.

Options

Examples

  msg.content = "This is a simple message." # a simple message
  msg.content = {:foo => :bar} # content is automatically encoded

Returns the content‘s size.

Returns the content type for the Message.

Examples

  case msg.content_type
    when "myapp/image"
      ctl.handle_image msg
      end
    when "myapp/audio"
      ctl.handle_audio msg
      end
  end

Sets the content type for the Message.

This should be set by the sending applicaton and indicates to recipients of the message how to interpret or decode the content.

By default, only dictionaries and maps are automatically given a content type. If this content type is replaced then retrieving the content will not behave correctly.

Options

Returns the correlation id of the Message.

*NOTE:* See +correlation_id=+ for details.

Sets the correlation id of the Message.

The correlation id can be used as part of a protocol for message exchange patterns; e.g., a requestion-response pattern might require the correlation id of the request and the response to match, or it might use the message id of the request as the correlation id on the response

*NOTE:* If the id is not a String then the id is setup using the object‘s string representation.

Options

  • id - the id

Returns the durability for the Message.

Sets the durability of the Message.

This is a hint to the messaging infrastructure that the message should be persisted or otherwise stored. This helps to ensure that th emessage is not lost during to failures or a shutdown.

Options

  • durable - the durability flag (def. false)

Returns the message id.

See +message_id=+ for details.

Sets the message id.

*NOTE:* this field must be a UUID type currently. A non-UUID value will be converted to a zero UUID, though a blank ID will be left untouched.

Options

  • id - the id

Examples

Returns the priority for the Message.

Sets the priority of the Message.

This may be used by the messaging infrastructure to prioritize delivery of messages with higher priority.

*NOTE:* If the priority is not an integer type then it is set using the object‘s integer representation. If the integer value is greater than 8-bits then only the first 8-bits are used.

Options

Returns all named properties.

*NOTE:* It is recommended to use the []= method for retrieving and setting properties. Using this method may result in non-deterministic behavior.

Returns whether the Message has been marked as redelivered.

This is a hint to the messaging infrastructure that if de-duplication is required, that this message should be examined to determine if it is a duplicate.

Options

Examples

  # processed is an array of processed message ids
  msg.redelivered = true if processed.include? msg.message_id

Returns the reply to address for the Message.

Sets the address to which replies should be sent for the Message.

*NOTE:* The address must be an instance of Address.

Options

Examples

  msg.reply_to = Qpid:Messaging::Address.new "my-responses"

Returns the subject of the Message.

Options

  puts "The subject is #{msg.subject}"

Sets the subject for the Message.

Options

Examples

  msg.subject = "mysubject"

Returns the time-to-live in milliseconds.

Sets the time-to-live in milliseconds.

Options

  • duration - the number of milliseconds

Returns the user id for the Message.

See +user_id=+ for details.

Sets the user id for the Message.

This should in general be the user-id which was used when authenticating the connection itself, as the messaging infrastructure will verify this.

See +Qpid::Messaging::Connection.authenticated_username+

*NOTE:* If the id is not a String then the id is set using the object‘s string representation.

Options

  • id - the id

[Validate]