public interface Message
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 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.
Modifier and Type | Field and Description |
---|---|
static byte |
BYTES_TYPE |
static byte |
DEFAULT_TYPE |
static SimpleString |
HDR_ACTUAL_EXPIRY_TIME
the actual time the message was expired.
|
static SimpleString |
HDR_CONTENT_TYPE
To define the mime-type of body messages.
|
static SimpleString |
HDR_DUPLICATE_DETECTION_ID
To be used with duplicate detection.
|
static SimpleString |
HDR_GROUP_ID
For the Message Grouping feature.
|
static SimpleString |
HDR_LARGE_BODY_SIZE
The body size of a large message before it was compressed.
|
static SimpleString |
HDR_LARGE_COMPRESSED
to determine if the Large Message was compressed.
|
static SimpleString |
HDR_LAST_VALUE_NAME
To be used with Last value queues.
|
static SimpleString |
HDR_ORIG_MESSAGE_ID
The original message ID before th emessage was transferred.
|
static SimpleString |
HDR_ORIGINAL_ADDRESS
The original address of a message when a message is transferred through DLQ or expiry
|
static SimpleString |
HDR_ORIGINAL_QUEUE
The original address of a message when a message is transferred through DLQ or expiry
|
static SimpleString |
HDR_SCHEDULED_DELIVERY_TIME
To be used with Scheduled Delivery.
|
static SimpleString |
HDR_VALIDATED_USER
The name of the validated user who sent the message.
|
static byte |
MAP_TYPE |
static byte |
OBJECT_TYPE |
static byte |
STREAM_TYPE |
static byte |
TEXT_TYPE |
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 |
getBodyBufferDuplicate()
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.
|
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(UUID userID)
Sets the user ID
|
Map<String,Object> |
toMap() |
Map<String,Object> |
toPropertyMap() |
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
|
static final SimpleString HDR_ACTUAL_EXPIRY_TIME
static final SimpleString HDR_ORIGINAL_ADDRESS
static final SimpleString HDR_ORIGINAL_QUEUE
static final SimpleString HDR_ORIG_MESSAGE_ID
static final SimpleString HDR_GROUP_ID
static final SimpleString HDR_LARGE_COMPRESSED
static final SimpleString HDR_LARGE_BODY_SIZE
static final SimpleString HDR_SCHEDULED_DELIVERY_TIME
static final SimpleString HDR_DUPLICATE_DETECTION_ID
static final SimpleString HDR_LAST_VALUE_NAME
static final SimpleString HDR_CONTENT_TYPE
static final SimpleString HDR_VALIDATED_USER
static final byte DEFAULT_TYPE
static final byte OBJECT_TYPE
static final byte TEXT_TYPE
static final byte BYTES_TYPE
static final byte MAP_TYPE
static final byte STREAM_TYPE
long getMessageID()
UUID getUserID()
SimpleString getAddress()
Message setAddress(SimpleString address)
address
- address to send the message tobyte getType()
See fields *_TYPE for possible values.
boolean isDurable()
Message setDurable(boolean durable)
durable
- true
to flag this message as durable, false
elselong getExpiration()
boolean isExpired()
Message setExpiration(long expiration)
expiration
- expiration timelong getTimestamp()
Message setTimestamp(long timestamp)
timestamp
- timestampbyte getPriority()
Values range from 0 (less priority) to 9 (more priority) inclusive.
Message setPriority(byte priority)
Value must be between 0 and 9 inclusive.
priority
- the new message priorityint getEncodeSize()
boolean isLargeMessage()
ActiveMQBuffer getBodyBuffer()
Message writeBodyBufferBytes(byte[] bytes)
Message writeBodyBufferString(String string)
ActiveMQBuffer getBodyBufferDuplicate()
Message putBooleanProperty(SimpleString key, boolean value)
key
- property namevalue
- property valueMessage putByteProperty(SimpleString key, byte value)
key
- property namevalue
- property valueMessage putByteProperty(String key, byte value)
putByteProperty(SimpleString, byte)
Message putBytesProperty(SimpleString key, byte[] value)
key
- property namevalue
- property valueMessage putBytesProperty(String key, byte[] value)
putBytesProperty(SimpleString, byte[])
Message putShortProperty(SimpleString key, short value)
key
- property namevalue
- property valueMessage putShortProperty(String key, short value)
putShortProperty(SimpleString, short)
Message putCharProperty(SimpleString key, char value)
key
- property namevalue
- property valueMessage putCharProperty(String key, char value)
putCharProperty(SimpleString, char)
Message putIntProperty(SimpleString key, int value)
key
- property namevalue
- property valueMessage putIntProperty(String key, int value)
putIntProperty(SimpleString, int)
Message putLongProperty(SimpleString key, long value)
key
- property namevalue
- property valueMessage putLongProperty(String key, long value)
putLongProperty(SimpleString, long)
Message putFloatProperty(SimpleString key, float value)
key
- property namevalue
- property valueMessage putFloatProperty(String key, float value)
putFloatProperty(SimpleString, float)
Message putDoubleProperty(SimpleString key, double value)
key
- property namevalue
- property valueMessage putDoubleProperty(String key, double value)
putDoubleProperty(SimpleString, double)
Message putStringProperty(SimpleString key, SimpleString value)
key
- property namevalue
- property valueMessage putStringProperty(String key, String value)
key
- property namevalue
- property valueMessage putObjectProperty(SimpleString key, Object value) throws ActiveMQPropertyConversionException
key
- property namevalue
- property valueActiveMQPropertyConversionException
- if the value is not one of the accepted property
types.Message putObjectProperty(String key, Object value) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
putObjectProperty(SimpleString, Object)
Object removeProperty(SimpleString key)
key
- property nameObject removeProperty(String key)
removeProperty(SimpleString)
boolean containsProperty(SimpleString key)
true
if this message contains a property with the given key, false
else.key
- property nameboolean containsProperty(String key)
containsProperty(SimpleString)
Boolean getBooleanProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a BooleanBoolean getBooleanProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getBooleanProperty(SimpleString)
Byte getByteProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a ByteByte getByteProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getByteProperty(SimpleString)
Double getDoubleProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a DoubleDouble getDoubleProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getDoubleProperty(SimpleString)
Integer getIntProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to an IntegerInteger getIntProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getIntProperty(SimpleString)
Long getLongProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a LongLong getLongProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getLongProperty(SimpleString)
Object getObjectProperty(SimpleString key)
Object getObjectProperty(String key)
getBooleanProperty(SimpleString)
Short getShortProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a ShortShort getShortProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getShortProperty(SimpleString)
Float getFloatProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a FloatFloat getFloatProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getFloatProperty(SimpleString)
String getStringProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a StringString getStringProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getStringProperty(SimpleString)
SimpleString getSimpleStringProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a SimpleStringSimpleString getSimpleStringProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getSimpleStringProperty(SimpleString)
byte[] getBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
- if the value can not be converted to a byte[]byte[] getBytesProperty(String key) throws ActiveMQPropertyConversionException
ActiveMQPropertyConversionException
getBytesProperty(SimpleString)
Set<SimpleString> getPropertyNames()
Map<String,Object> toMap()
Copyright © 2017 JBoss by Red Hat. All rights reserved.