org.apache.activemq.artemis.api.core

## Interface Message

- All Known Subinterfaces:
    ClientMessage

      public interface Message

  A Message is a routable instance that has a payload.

  The payload (the "body") is opaque to the messaging system. A Message also has a fixed set of headers (required by the messaging system) and properties (defined by the users) that can be used by the messaging system to route the message (e.g. to ensure it matches a queue filter).

  ## Message Properties

  Message can contain properties specified by the users. It is possible to convert from some types to other types as specified by the following table:

       |        | boolean byte short int long float double String byte[]
       |----------------------------------------------------------------
       |boolean |    X                                      X
       |byte    |          X    X    X   X                  X
       |short   |               X    X   X                  X
       |int     |                    X   X                  X
       |long    |                        X                  X
       |float   |                              X     X      X
       |double  |                                    X      X
       |String  |    X     X    X    X   X     X     X      X
       |byte[]  |                                                   X
       |-----------------------------------------------------------------

  If conversion is not allowed (for example calling `getFloatProperty` on a property set a `boolean`), a `ActiveMQPropertyConversionException` will be thrown.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static byte` | `BYTES_TYPE`
    `static byte` | `DEFAULT_TYPE`
    `static SimpleString` | `HDR_ACTUAL_EXPIRY_TIME`
    `static SimpleString` | `HDR_DUPLICATE_DETECTION_ID`
    `static SimpleString` | `HDR_GROUP_ID`
    `static SimpleString` | `HDR_LARGE_BODY_SIZE`
    `static SimpleString` | `HDR_LARGE_COMPRESSED`
    `static SimpleString` | `HDR_LAST_VALUE_NAME`
    `static SimpleString` | `HDR_ORIG_MESSAGE_ID`
    `static SimpleString` | `HDR_ORIGINAL_ADDRESS`
    `static SimpleString` | `HDR_ORIGINAL_QUEUE`
    `static SimpleString` | `HDR_SCHEDULED_DELIVERY_TIME`
    `static byte` | `MAP_TYPE`
    `static byte` | `OBJECT_TYPE`
    `static byte` | `STREAM_TYPE`
    `static byte` | `TEXT_TYPE`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsProperty(SimpleString key)` Returns `true` if this message contains a property with the given key, `false` else.
    `boolean` | `containsProperty(String key)`
    `SimpleString` | `getAddress()` Returns the address this message is sent to.
    `ActiveMQBuffer` | `getBodyBuffer()` Returns the message body as an ActiveMQBuffer
    `ActiveMQBuffer` | `getBodyBufferCopy()` Returns a copy of the message body as an ActiveMQBuffer.
    `Boolean` | `getBooleanProperty(SimpleString key)` Returns the property corresponding to the specified key as a Boolean.
    `Boolean` | `getBooleanProperty(String key)`
    `Byte` | `getByteProperty(SimpleString key)` Returns the property corresponding to the specified key as a Byte.
    `Byte` | `getByteProperty(String key)`
    `byte[]` | `getBytesProperty(SimpleString key)` Returns the property corresponding to the specified key as a byte[].
    `byte[]` | `getBytesProperty(String key)`
    `Double` | `getDoubleProperty(SimpleString key)` Returns the property corresponding to the specified key as a Double.
    `Double` | `getDoubleProperty(String key)`
    `int` | `getEncodeSize()` Returns the size of the encoded message.
    `long` | `getExpiration()` Returns the expiration time of this message.
    `Float` | `getFloatProperty(SimpleString key)` Returns the property corresponding to the specified key as a Float.
    `Float` | `getFloatProperty(String key)`
    `Integer` | `getIntProperty(SimpleString key)` Returns the property corresponding to the specified key as an Integer.
    `Integer` | `getIntProperty(String key)`
    `Long` | `getLongProperty(SimpleString key)` Returns the property corresponding to the specified key as a Long.
    `Long` | `getLongProperty(String key)`
    `long` | `getMessageID()` Returns the messageID.
    `Object` | `getObjectProperty(SimpleString key)` Returns the property corresponding to the specified key
    `Object` | `getObjectProperty(String key)`
    `byte` | `getPriority()` Returns the message priority.
    `Set<SimpleString>` | `getPropertyNames()` Returns all the names of the properties for this message.
    `Short` | `getShortProperty(SimpleString key)` Returns the property corresponding to the specified key as a Short.
    `Short` | `getShortProperty(String key)`
    `SimpleString` | `getSimpleStringProperty(SimpleString key)` Returns the property corresponding to the specified key as a SimpleString.
    `SimpleString` | `getSimpleStringProperty(String key)`
    `String` | `getStringProperty(SimpleString key)` Returns the property corresponding to the specified key as a String.
    `String` | `getStringProperty(String key)`
    `long` | `getTimestamp()` Returns the message timestamp.
    `byte` | `getType()` Returns this message type.
    `org.apache.activemq.artemis.utils.UUID` | `getUserID()` Returns the userID - this is an optional user specified UUID that can be set to identify the message and will be passed around with the message
    `boolean` | `isDurable()` Returns whether this message is durable or not.
    `boolean` | `isExpired()` Returns whether this message is expired or not.
    `boolean` | `isLargeMessage()` Returns whether this message is a large message or a regular message.
    `Message` | `putBooleanProperty(SimpleString key, boolean value)` Puts a boolean property in this message.
    `Message` | `putBooleanProperty(String key, boolean value)`
    `Message` | `putByteProperty(SimpleString key, byte value)` Puts a byte property in this message.
    `Message` | `putByteProperty(String key, byte value)`
    `Message` | `putBytesProperty(SimpleString key, byte[] value)` Puts a byte[] property in this message.
    `Message` | `putBytesProperty(String key, byte[] value)`
    `Message` | `putCharProperty(SimpleString key, char value)` Puts a char property in this message.
    `Message` | `putCharProperty(String key, char value)`
    `Message` | `putDoubleProperty(SimpleString key, double value)` Puts a double property in this message.
    `Message` | `putDoubleProperty(String key, double value)`
    `Message` | `putFloatProperty(SimpleString key, float value)` Puts a float property in this message.
    `Message` | `putFloatProperty(String key, float value)`
    `Message` | `putIntProperty(SimpleString key, int value)` Puts an int property in this message.
    `Message` | `putIntProperty(String key, int value)`
    `Message` | `putLongProperty(SimpleString key, long value)` Puts a long property in this message.
    `Message` | `putLongProperty(String key, long value)`
    `Message` | `putObjectProperty(SimpleString key, Object value)` Puts an Object property in this message.
    `Message` | `putObjectProperty(String key, Object value)`
    `Message` | `putShortProperty(SimpleString key, short value)` Puts a short property in this message.
    `Message` | `putShortProperty(String key, short value)`
    `Message` | `putStringProperty(SimpleString key, SimpleString value)` Puts a SimpleString property in this message.
    `Message` | `putStringProperty(String key, String value)` Puts a String property in this message.
    `Object` | `removeProperty(SimpleString key)` Removes the property corresponding to the specified key.
    `Object` | `removeProperty(String key)`
    `Message` | `setAddress(SimpleString address)` Sets the address to send this message to.
    `Message` | `setDurable(boolean durable)` Sets whether this message is durable or not.
    `Message` | `setExpiration(long expiration)` Sets the expiration of this message.
    `Message` | `setPriority(byte priority)` Sets the message priority.
    `Message` | `setTimestamp(long timestamp)` Sets the message timestamp.
    `Message` | `setUserID(org.apache.activemq.artemis.utils.UUID userID)` Sets the user ID
    `Map<String,Object>` | `toMap()`
    `Message` | `writeBodyBufferBytes(byte[] bytes)` Writes the input byte array to the message body ActiveMQBuffer
    `Message` | `writeBodyBufferString(String string)` Writes the input String to the message body ActiveMQBuffer

- - ### Field Detail

    - #### HDR_ACTUAL_EXPIRY_TIME

          static final SimpleString HDR_ACTUAL_EXPIRY_TIME

    - #### HDR_ORIGINAL_ADDRESS

          static final SimpleString HDR_ORIGINAL_ADDRESS

    - #### HDR_ORIGINAL_QUEUE

          static final SimpleString HDR_ORIGINAL_QUEUE

    - #### HDR_ORIG_MESSAGE_ID

          static final SimpleString HDR_ORIG_MESSAGE_ID

    - #### HDR_GROUP_ID

          static final SimpleString HDR_GROUP_ID

    - #### HDR_LARGE_COMPRESSED

          static final SimpleString HDR_LARGE_COMPRESSED

    - #### HDR_LARGE_BODY_SIZE

          static final SimpleString HDR_LARGE_BODY_SIZE

    - #### HDR_SCHEDULED_DELIVERY_TIME

          static final SimpleString HDR_SCHEDULED_DELIVERY_TIME

    - #### HDR_DUPLICATE_DETECTION_ID

          static final SimpleString HDR_DUPLICATE_DETECTION_ID

    - #### HDR_LAST_VALUE_NAME

          static final SimpleString HDR_LAST_VALUE_NAME

    - #### DEFAULT_TYPE

          static final byte DEFAULT_TYPE

      See Also:
        Constant Field Values

    - #### OBJECT_TYPE

          static final byte OBJECT_TYPE

      See Also:
        Constant Field Values

    - #### TEXT_TYPE

          static final byte TEXT_TYPE

      See Also:
        Constant Field Values

    - #### BYTES_TYPE

          static final byte BYTES_TYPE

      See Also:
        Constant Field Values

    - #### MAP_TYPE

          static final byte MAP_TYPE

      See Also:
        Constant Field Values

    - #### STREAM_TYPE

          static final byte STREAM_TYPE

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getMessageID

          long getMessageID()

      Returns the messageID.
      The messageID is set when the message is handled by the server.

    - #### getUserID

          org.apache.activemq.artemis.utils.UUID getUserID()

      Returns the userID - this is an optional user specified UUID that can be set to identify the message and will be passed around with the message
      Returns:
        the user id

    - #### setUserID

          Message setUserID(org.apache.activemq.artemis.utils.UUID userID)

      Sets the user ID
      Parameters:
        `userID` -

    - #### getAddress

          SimpleString getAddress()

      Returns the address this message is sent to.

    - #### setAddress

          Message setAddress(SimpleString address)

      Sets the address to send this message to.
      Parameters:
        `address` - address to send the message to

    - #### getType

          byte getType()

      Returns this message type.

      See fields *_TYPE for possible values.

    - #### isDurable

          boolean isDurable()

      Returns whether this message is durable or not.

    - #### setDurable

          Message setDurable(boolean durable)

      Sets whether this message is durable or not.
      Parameters:
        `durable` - `true` to flag this message as durable, `false` else

    - #### getExpiration

          long getExpiration()

      Returns the expiration time of this message.

    - #### isExpired

          boolean isExpired()

      Returns whether this message is expired or not.

    - #### setExpiration

          Message setExpiration(long expiration)

      Sets the expiration of this message.
      Parameters:
        `expiration` - expiration time

    - #### getTimestamp

          long getTimestamp()

      Returns the message timestamp.
      The timestamp corresponds to the time this message was handled by an ActiveMQ Artemis server.

    - #### setTimestamp

          Message setTimestamp(long timestamp)

      Sets the message timestamp.
      Parameters:
        `timestamp` - timestamp

    - #### getPriority

          byte getPriority()

      Returns the message priority.

      Values range from 0 (less priority) to 9 (more priority) inclusive.

    - #### setPriority

          Message setPriority(byte priority)

      Sets the message priority.

      Value must be between 0 and 9 inclusive.

      Parameters:
        `priority` - the new message priority

    - #### getEncodeSize

          int getEncodeSize()

      Returns the size of the encoded message.

    - #### isLargeMessage

          boolean isLargeMessage()

      Returns whether this message is a large message or a regular message.

    - #### getBodyBuffer

          ActiveMQBuffer getBodyBuffer()

      Returns the message body as an ActiveMQBuffer

    - #### writeBodyBufferBytes

          Message writeBodyBufferBytes(byte[] bytes)

      Writes the input byte array to the message body ActiveMQBuffer

    - #### writeBodyBufferString

          Message writeBodyBufferString(String string)

      Writes the input String to the message body ActiveMQBuffer

    - #### getBodyBufferCopy

          ActiveMQBuffer getBodyBufferCopy()

      Returns a copy of the message body as an ActiveMQBuffer. Any modification of this buffer should not impact the underlying buffer.

    - #### putBooleanProperty

          Message putBooleanProperty(SimpleString key,
                                     boolean value)

      Puts a boolean property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putBooleanProperty

          Message putBooleanProperty(String key,
                                     boolean value)

      See Also:
        `putBooleanProperty(SimpleString, boolean)`

    - #### putByteProperty

          Message putByteProperty(SimpleString key,
                                  byte value)

      Puts a byte property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putByteProperty

          Message putByteProperty(String key,
                                  byte value)

      See Also:
        `putByteProperty(SimpleString, byte)`

    - #### putBytesProperty

          Message putBytesProperty(SimpleString key,
                                   byte[] value)

      Puts a byte[] property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putBytesProperty

          Message putBytesProperty(String key,
                                   byte[] value)

      See Also:
        `putBytesProperty(SimpleString, byte[])`

    - #### putShortProperty

          Message putShortProperty(SimpleString key,
                                   short value)

      Puts a short property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putShortProperty

          Message putShortProperty(String key,
                                   short value)

      See Also:
        `putShortProperty(SimpleString, short)`

    - #### putCharProperty

          Message putCharProperty(SimpleString key,
                                  char value)

      Puts a char property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putCharProperty

          Message putCharProperty(String key,
                                  char value)

      See Also:
        `putCharProperty(SimpleString, char)`

    - #### putIntProperty

          Message putIntProperty(SimpleString key,
                                 int value)

      Puts an int property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putIntProperty

          Message putIntProperty(String key,
                                 int value)

      See Also:
        `putIntProperty(SimpleString, int)`

    - #### putLongProperty

          Message putLongProperty(SimpleString key,
                                  long value)

      Puts a long property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putLongProperty

          Message putLongProperty(String key,
                                  long value)

      See Also:
        `putLongProperty(SimpleString, long)`

    - #### putFloatProperty

          Message putFloatProperty(SimpleString key,
                                   float value)

      Puts a float property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putFloatProperty

          Message putFloatProperty(String key,
                                   float value)

      See Also:
        `putFloatProperty(SimpleString, float)`

    - #### putDoubleProperty

          Message putDoubleProperty(SimpleString key,
                                    double value)

      Puts a double property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putDoubleProperty

          Message putDoubleProperty(String key,
                                    double value)

      See Also:
        `putDoubleProperty(SimpleString, double)`

    - #### putStringProperty

          Message putStringProperty(SimpleString key,
                                    SimpleString value)

      Puts a SimpleString property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putStringProperty

          Message putStringProperty(String key,
                                    String value)

      Puts a String property in this message.
      Parameters:
        `key` - property name
        `value` - property value

    - #### putObjectProperty

          Message putObjectProperty(SimpleString key,
                                    Object value)
                             throws ActiveMQPropertyConversionException

      Puts an Object property in this message.
      Accepted types are:
      - Boolean
      - Byte
      - Short
      - Character
      - Integer
      - Long
      - Float
      - Double
      - String
      - SimpleString
      Using any other type will throw a PropertyConversionException.
      Parameters:
        `key` - property name
        `value` - property value
      Throws:
        `ActiveMQPropertyConversionException` - if the value is not one of the accepted property types.

    - #### putObjectProperty

          Message putObjectProperty(String key,
                                    Object value)
                             throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `putObjectProperty(SimpleString, Object)`

    - #### removeProperty

          Object removeProperty(SimpleString key)

      Removes the property corresponding to the specified key.
      Parameters:
        `key` - property name
      Returns:
        the value corresponding to the specified key or @{code null}

    - #### removeProperty

          Object removeProperty(String key)

      See Also:
        `removeProperty(SimpleString)`

    - #### containsProperty

          boolean containsProperty(SimpleString key)

      Returns `true` if this message contains a property with the given key, `false` else.
      Parameters:
        `key` - property name

    - #### containsProperty

          boolean containsProperty(String key)

      See Also:
        `containsProperty(SimpleString)`

    - #### getBooleanProperty

          Boolean getBooleanProperty(SimpleString key)
                              throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a Boolean.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a Boolean

    - #### getBooleanProperty

          Boolean getBooleanProperty(String key)
                              throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getBooleanProperty(SimpleString)`

    - #### getByteProperty

          Byte getByteProperty(SimpleString key)
                        throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a Byte.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a Byte

    - #### getByteProperty

          Byte getByteProperty(String key)
                        throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getByteProperty(SimpleString)`

    - #### getDoubleProperty

          Double getDoubleProperty(SimpleString key)
                            throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a Double.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a Double

    - #### getDoubleProperty

          Double getDoubleProperty(String key)
                            throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getDoubleProperty(SimpleString)`

    - #### getIntProperty

          Integer getIntProperty(SimpleString key)
                          throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as an Integer.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to an Integer

    - #### getIntProperty

          Integer getIntProperty(String key)
                          throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getIntProperty(SimpleString)`

    - #### getLongProperty

          Long getLongProperty(SimpleString key)
                        throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a Long.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a Long

    - #### getLongProperty

          Long getLongProperty(String key)
                        throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getLongProperty(SimpleString)`

    - #### getObjectProperty

          Object getObjectProperty(SimpleString key)

      Returns the property corresponding to the specified key

    - #### getObjectProperty

          Object getObjectProperty(String key)

      See Also:
        `getBooleanProperty(SimpleString)`

    - #### getShortProperty

          Short getShortProperty(SimpleString key)
                          throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a Short.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a Short

    - #### getShortProperty

          Short getShortProperty(String key)
                          throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getShortProperty(SimpleString)`

    - #### getFloatProperty

          Float getFloatProperty(SimpleString key)
                          throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a Float.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a Float

    - #### getFloatProperty

          Float getFloatProperty(String key)
                          throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getFloatProperty(SimpleString)`

    - #### getStringProperty

          String getStringProperty(SimpleString key)
                            throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a String.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a String

    - #### getStringProperty

          String getStringProperty(String key)
                            throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getStringProperty(SimpleString)`

    - #### getSimpleStringProperty

          SimpleString getSimpleStringProperty(SimpleString key)
                                        throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a SimpleString.
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a SimpleString

    - #### getSimpleStringProperty

          SimpleString getSimpleStringProperty(String key)
                                        throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getSimpleStringProperty(SimpleString)`

    - #### getBytesProperty

          byte[] getBytesProperty(SimpleString key)
                           throws ActiveMQPropertyConversionException

      Returns the property corresponding to the specified key as a byte[].
      Throws:
        `ActiveMQPropertyConversionException` - if the value can not be converted to a byte[]

    - #### getBytesProperty

          byte[] getBytesProperty(String key)
                           throws ActiveMQPropertyConversionException

      Throws:
        `ActiveMQPropertyConversionException`
      See Also:
        `getBytesProperty(SimpleString)`

    - #### getPropertyNames

          Set<SimpleString> getPropertyNames()

      Returns all the names of the properties for this message.

    - #### toMap

          Map<String,Object> toMap()

      Returns:
        Returns the message in Map form, useful when encoding to JSON

Copyright © 2015. All rights reserved.