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.
User cases that will be covered by Message
Receiving a buffer:
Message encode = new CoreMessage(); // or any other implementation
encode.receiveBuffer(buffer);
Sending to a buffer:
Message encode;
size = encode.getEncodeSize();
encode.encodeDirectly(bufferOutput);
Modifier and Type | Field and Description |
---|---|
static byte |
BYTES_TYPE |
static byte |
DEFAULT_TYPE |
static byte |
EMBEDDED_TYPE
The message will contain another message persisted through
EmbedMessageUtil |
static SimpleString |
HDR_ACTUAL_EXPIRY_TIME
the actual time the message was expired.
|
static SimpleString |
HDR_BRIDGE_DUPLICATE_ID |
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_GROUP_SEQUENCE |
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 the message was transferred.
|
static SimpleString |
HDR_ORIGINAL_ADDRESS
The original address of a message when a message is diverted or 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_PREFIX
The prefix used (if any) when sending this message.
|
static SimpleString |
HDR_ROUTE_TO_ACK_IDS |
static SimpleString |
HDR_ROUTE_TO_IDS |
static SimpleString |
HDR_ROUTING_TYPE
The Routing Type for this message.
|
static SimpleString |
HDR_SCALEDOWN_TO_IDS |
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 int |
memoryOffset |
static byte |
OBJECT_TYPE |
static byte |
STREAM_TYPE |
static byte |
TEXT_TYPE |
Modifier and Type | Method and Description |
---|---|
default boolean |
acceptsConsumer(long uniqueConsumerID) |
default void |
clearInternalProperties() |
boolean |
containsProperty(SimpleString key) |
boolean |
containsProperty(String key) |
Message |
copy()
It will generate a new instance of the message encode, being a deep copy, new properties, new everything
|
Message |
copy(long newID)
It will generate a new instance of the message encode, being a deep copy, new properties, new everything
|
int |
decrementDurableRefCount() |
int |
decrementRefCount() |
String |
getAddress() |
SimpleString |
getAddressSimpleString() |
Object |
getAnnotation(SimpleString key) |
default String |
getAnnotationString(SimpleString key) |
default ActiveMQBuffer |
getBodyBuffer()
Deprecated.
do not use this, use through ICoreMessage or ClientMessage
|
default InputStream |
getBodyInputStream()
Deprecated.
do not use this, use through ICoreMessage or ClientMessage
|
Boolean |
getBooleanProperty(SimpleString key) |
Boolean |
getBooleanProperty(String key) |
io.netty.buffer.ByteBuf |
getBuffer() |
Byte |
getByteProperty(SimpleString key) |
Byte |
getByteProperty(String key) |
byte[] |
getBytesProperty(SimpleString key) |
byte[] |
getBytesProperty(String key) |
default String |
getConnectionID() |
RefCountMessageListener |
getContext()
Context can be used by the application server to inject extra control, like a protocol specific on the server.
|
default Object |
getCorrelationID() |
Double |
getDoubleProperty(SimpleString key) |
Double |
getDoubleProperty(String key) |
default byte[] |
getDuplicateIDBytes()
it will translate a property named HDR_DUPLICATE_DETECTION_ID.
|
default Object |
getDuplicateProperty() |
int |
getEncodeSize()
Returns the size of the encoded message.
|
long |
getExpiration()
Returns the expiration time of this message.
|
default byte[] |
getExtraBytesProperty(SimpleString key) |
Float |
getFloatProperty(SimpleString key) |
Float |
getFloatProperty(String key) |
default SimpleString |
getGroupID() |
default int |
getGroupSequence() |
Integer |
getIntProperty(SimpleString key) |
Integer |
getIntProperty(String key) |
default SimpleString |
getLastValueProperty() |
Long |
getLongProperty(SimpleString key) |
Long |
getLongProperty(String key) |
int |
getMemoryEstimate() |
long |
getMessageID()
Returns the messageID.
|
Object |
getObjectProperty(SimpleString key) |
Object |
getObjectProperty(String key) |
long |
getPersistentSize()
This is the size of the message when persisted on disk which is used for metrics tracking
Note that even if the message itself is not persisted on disk (ie non-durable) this value is
still used for metrics tracking
If a normal message it will be the encoded message size
If a large message it will be encoded message size + large message body size
|
Persister<Message> |
getPersister() |
int |
getPersistSize() |
byte |
getPriority()
Returns the message priority.
|
Set<SimpleString> |
getPropertyNames()
Returns all the names of the properties for this message.
|
int |
getRefCount() |
SimpleString |
getReplyTo() |
default RoutingType |
getRoutingType() |
Long |
getScheduledDeliveryTime()
Used to calculate what is the delivery time.
|
Short |
getShortProperty(SimpleString key) |
Short |
getShortProperty(String key) |
SimpleString |
getSimpleStringProperty(SimpleString key) |
SimpleString |
getSimpleStringProperty(String key) |
String |
getStringProperty(SimpleString key) |
String |
getStringProperty(String key) |
long |
getTimestamp() |
default byte |
getType()
Deprecated.
do not use this, use through ICoreMessage or ClientMessage
|
Object |
getUserID()
This represents historically the JMSMessageID.
|
default String |
getValidatedUserID() |
int |
incrementDurableRefCount() |
int |
incrementRefCount() |
boolean |
isDurable()
Returns whether this message is durable or not.
|
default boolean |
isExpired()
Returns whether this message is expired or not.
|
default boolean |
isLargeMessage() |
void |
messageChanged()
WARNING: Calling this method on a AMQPMessage will allow the non mutable part of the message to be modified.
|
void |
persist(ActiveMQBuffer targetRecord) |
Message |
putBooleanProperty(SimpleString key,
boolean value) |
Message |
putBooleanProperty(String key,
boolean value) |
Message |
putByteProperty(SimpleString key,
byte value) |
Message |
putByteProperty(String key,
byte value) |
Message |
putBytesProperty(SimpleString key,
byte[] value) |
Message |
putBytesProperty(String key,
byte[] value) |
Message |
putCharProperty(SimpleString key,
char value) |
Message |
putCharProperty(String key,
char value) |
Message |
putDoubleProperty(SimpleString key,
double value) |
Message |
putDoubleProperty(String key,
double value) |
default Message |
putExtraBytesProperty(SimpleString key,
byte[] value) |
Message |
putFloatProperty(SimpleString key,
float value) |
Message |
putFloatProperty(String key,
float value) |
Message |
putIntProperty(SimpleString key,
int value) |
Message |
putIntProperty(String key,
int value) |
Message |
putLongProperty(SimpleString key,
long value) |
Message |
putLongProperty(String key,
long value) |
Message |
putObjectProperty(SimpleString key,
Object value) |
Message |
putObjectProperty(String key,
Object value) |
Message |
putShortProperty(SimpleString key,
short value) |
Message |
putShortProperty(String key,
short value) |
Message |
putStringProperty(SimpleString key,
SimpleString value) |
Message |
putStringProperty(SimpleString key,
String value) |
Message |
putStringProperty(String key,
String value)
Puts a String property in this message.
|
void |
receiveBuffer(io.netty.buffer.ByteBuf buffer)
Used to receive this message from an encoded medium buffer
|
default void |
reencode() |
default void |
referenceOriginalMessage(Message original,
String originalQueue) |
default void |
rejectConsumer(long uniqueConsumerID) |
default void |
releaseBuffer() |
void |
reloadPersistence(ActiveMQBuffer record) |
default Object |
removeAnnotation(SimpleString key) |
default byte[] |
removeExtraBytesProperty(SimpleString key) |
Object |
removeProperty(SimpleString key) |
Object |
removeProperty(String key) |
void |
sendBuffer(io.netty.buffer.ByteBuf buffer,
int deliveryCount)
Used to send this message to an encoded medium buffer.
|
Message |
setAddress(SimpleString address)
This will set the address on CoreMessage.
|
Message |
setAddress(String address)
Look at
setAddress(SimpleString) for the doc. |
default Message |
setAnnotation(SimpleString key,
Object value)
Callers must call
reencode() in order to be sent to clients |
Message |
setBuffer(io.netty.buffer.ByteBuf buffer)
The buffer will belong to this message, until release is called.
|
default Message |
setConnectionID(String connectionID) |
Message |
setContext(RefCountMessageListener context) |
default Message |
setCorrelationID(Object correlationID) |
Message |
setDurable(boolean durable)
Sets whether this message is durable or not.
|
Message |
setExpiration(long expiration)
Sets the expiration of this message.
|
default Message |
setGroupID(SimpleString groupID) |
default Message |
setGroupID(String groupID) |
default Message |
setGroupSequence(int sequence) |
default Message |
setLastValueProperty(SimpleString lastValueName) |
Message |
setMessageID(long id) |
Message |
setPriority(byte priority)
Sets the message priority.
|
Message |
setReplyTo(SimpleString address) |
default Message |
setRoutingType(RoutingType routingType) |
default Message |
setScheduledDeliveryTime(Long time) |
Message |
setTimestamp(long timestamp) |
default Message |
setType(byte type)
Deprecated.
do not use this, use through ICoreMessage or ClientMessage
|
Message |
setUserID(Object userID) |
default Message |
setValidatedUserID(String validatedUserID) |
ICoreMessage |
toCore()
This should make you convert your message into Core format.
|
ICoreMessage |
toCore(CoreMessageObjectPools coreMessageObjectPools)
This should make you convert your message into Core format.
|
default Map<String,Object> |
toMap() |
default Map<String,Object> |
toPropertyMap() |
static final int memoryOffset
static final SimpleString HDR_ROUTE_TO_IDS
static final SimpleString HDR_SCALEDOWN_TO_IDS
static final SimpleString HDR_ROUTE_TO_ACK_IDS
static final SimpleString HDR_BRIDGE_DUPLICATE_ID
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_GROUP_SEQUENCE
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 SimpleString HDR_ROUTING_TYPE
static final SimpleString HDR_PREFIX
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
static final byte EMBEDDED_TYPE
EmbedMessageUtil
default void clearInternalProperties()
default RoutingType getRoutingType()
default Message setRoutingType(RoutingType routingType)
default SimpleString getLastValueProperty()
default Message setLastValueProperty(SimpleString lastValueName)
@Deprecated default InputStream getBodyInputStream()
@Deprecated default ActiveMQBuffer getBodyBuffer()
@Deprecated default byte getType()
@Deprecated default Message setType(byte type)
void messageChanged()
Long getScheduledDeliveryTime()
RefCountMessageListener getContext()
default SimpleString getGroupID()
default Message setGroupID(SimpleString groupID)
default int getGroupSequence()
default Message setGroupSequence(int sequence)
default Object getCorrelationID()
SimpleString getReplyTo()
Message setReplyTo(SimpleString address)
Message setContext(RefCountMessageListener context)
Message setBuffer(io.netty.buffer.ByteBuf buffer)
io.netty.buffer.ByteBuf getBuffer()
Message copy()
Message copy(long newID)
default boolean acceptsConsumer(long uniqueConsumerID)
default void rejectConsumer(long uniqueConsumerID)
long getMessageID()
default String getConnectionID()
Message setMessageID(long id)
default boolean isLargeMessage()
long getExpiration()
Message setExpiration(long expiration)
expiration
- expiration timedefault boolean isExpired()
Object getUserID()
default String getValidatedUserID()
boolean isDurable()
Message setDurable(boolean durable)
durable
- true
to flag this message as durable, false
elseString getAddress()
Message setAddress(String address)
setAddress(SimpleString)
for the doc.address
- SimpleString getAddressSimpleString()
Message setAddress(SimpleString address)
address
- long getTimestamp()
Message setTimestamp(long timestamp)
byte 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 priorityvoid receiveBuffer(io.netty.buffer.ByteBuf buffer)
void sendBuffer(io.netty.buffer.ByteBuf buffer, int deliveryCount)
buffer
- the buffer used.deliveryCount
- Some protocols (AMQP) will have this as part of the message.int getPersistSize()
void persist(ActiveMQBuffer targetRecord)
void reloadPersistence(ActiveMQBuffer record)
default void releaseBuffer()
default void reencode()
default void referenceOriginalMessage(Message original, String originalQueue)
default byte[] getDuplicateIDBytes()
default Message putExtraBytesProperty(SimpleString key, byte[] value)
default byte[] getExtraBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException
default byte[] removeExtraBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException
default Object getDuplicateProperty()
Message putBooleanProperty(SimpleString key, boolean value)
Message putByteProperty(SimpleString key, byte value)
Message putBytesProperty(SimpleString key, byte[] value)
Message putShortProperty(SimpleString key, short value)
Message putCharProperty(SimpleString key, char value)
Message putIntProperty(SimpleString key, int value)
Message putLongProperty(SimpleString key, long value)
Message putFloatProperty(SimpleString key, float value)
Message putDoubleProperty(SimpleString key, double value)
Message putStringProperty(String key, String value)
key
- property namevalue
- property valueMessage putObjectProperty(String key, Object value) throws ActiveMQPropertyConversionException
Message putObjectProperty(SimpleString key, Object value) throws ActiveMQPropertyConversionException
boolean containsProperty(String key)
Boolean getBooleanProperty(String key) throws ActiveMQPropertyConversionException
Byte getByteProperty(String key) throws ActiveMQPropertyConversionException
Double getDoubleProperty(String key) throws ActiveMQPropertyConversionException
Integer getIntProperty(String key) throws ActiveMQPropertyConversionException
Long getLongProperty(String key) throws ActiveMQPropertyConversionException
Short getShortProperty(String key) throws ActiveMQPropertyConversionException
Float getFloatProperty(String key) throws ActiveMQPropertyConversionException
String getStringProperty(String key) throws ActiveMQPropertyConversionException
SimpleString getSimpleStringProperty(String key) throws ActiveMQPropertyConversionException
byte[] getBytesProperty(String key) throws ActiveMQPropertyConversionException
Object removeProperty(SimpleString key)
boolean containsProperty(SimpleString key)
Boolean getBooleanProperty(SimpleString key) throws ActiveMQPropertyConversionException
Byte getByteProperty(SimpleString key) throws ActiveMQPropertyConversionException
Double getDoubleProperty(SimpleString key) throws ActiveMQPropertyConversionException
Integer getIntProperty(SimpleString key) throws ActiveMQPropertyConversionException
Long getLongProperty(SimpleString key) throws ActiveMQPropertyConversionException
Object getObjectProperty(SimpleString key)
default Object removeAnnotation(SimpleString key)
default String getAnnotationString(SimpleString key)
Object getAnnotation(SimpleString key)
default Message setAnnotation(SimpleString key, Object value)
reencode()
in order to be sent to clientsShort getShortProperty(SimpleString key) throws ActiveMQPropertyConversionException
Float getFloatProperty(SimpleString key) throws ActiveMQPropertyConversionException
String getStringProperty(SimpleString key) throws ActiveMQPropertyConversionException
SimpleString getSimpleStringProperty(SimpleString key) throws ActiveMQPropertyConversionException
byte[] getBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException
Message putStringProperty(SimpleString key, SimpleString value)
Message putStringProperty(SimpleString key, String value)
int getEncodeSize()
Set<SimpleString> getPropertyNames()
int getRefCount()
int incrementDurableRefCount()
int decrementDurableRefCount()
default Map<String,Object> toMap()
default Map<String,Object> toPropertyMap()
ICoreMessage toCore()
ICoreMessage toCore(CoreMessageObjectPools coreMessageObjectPools)
int getMemoryEstimate()
long getPersistentSize() throws ActiveMQException
ActiveMQException
Copyright © 2019 JBoss by Red Hat. All rights reserved.