Interface Message
- All Known Subinterfaces:
ClientMessage
,ICoreMessage
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.
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);
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Predicate<SimpleString>
static final byte
static final byte
static final byte
The message will contain another message persisted through org.apache.activemq.artemis.spi.core.protocol.EmbedMessageUtilstatic final SimpleString
the actual time the message was expired.static final SimpleString
static final SimpleString
To define the mime-type of body messages.static final SimpleString
To be used with duplicate detection.static final SimpleString
For the Message Grouping feature.static final SimpleString
static final SimpleString
The time at which the message arrived at the broker.static final SimpleString
The body size of a large message before it was compressed.static final SimpleString
to determine if the Large Message was compressed.static final SimpleString
To be used with Last value queues.static final SimpleString
The original message ID before the message was transferred.static final SimpleString
The original routing type of a message before getting transferred through DLQ or expirystatic final SimpleString
The original address of a message when a message is diverted or transferred through DLQ or expirystatic final SimpleString
The original address of a message when a message is transferred through DLQ or expirystatic final SimpleString
The prefix used (if any) when sending this message.static final SimpleString
static final SimpleString
static final SimpleString
The Routing Type for this message.static final SimpleString
static final SimpleString
To be used with Scheduled Delivery.static final SimpleString
The name of the validated user who sent the message.static final Predicate<SimpleString>
static final byte
This is to embedd Large Messages from other protocolstatic final byte
static final int
static final byte
static final SimpleString
static final byte
static final byte
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
acceptsConsumer
(long uniqueConsumerID) default void
default void
boolean
containsProperty
(String key) boolean
copy()
It will generate a new instance of the message encode, being a deep copy, new properties, new everythingcopy
(long newID) It will generate a new instance of the message encode, being a deep copy, new properties, new everythingdefault Message
copy
(long newID, boolean isExpiryOrDLQ) It will generate a new instance of the message encode, being a deep copy, new properties, new everythingint
int
default String
default ActiveMQBuffer
Deprecated.do not use this, use through ICoreMessage or ClientMessage Warning: if you need to read the content of a message use getDataBuffer().default InputStream
Deprecated.do not use this, use through ICoreMessage or ClientMessagegetBooleanProperty
(String key) default Object
getByteProperty
(String key) byte[]
getBytesProperty
(String key) byte[]
default String
default Object
getDoubleProperty
(String key) default byte[]
it will translate a property named HDR_DUPLICATE_DETECTION_ID.default Object
int
int
Returns the size of the encoded message.long
Returns the expiration time of this message.default byte[]
getFloatProperty
(String key) default SimpleString
default int
default Long
getIntProperty
(String key) default SimpleString
getLongProperty
(String key) int
long
Returns the messageID.getObjectProperty
(String key) default Object
default int
The first estimate that's been calculated without any updates.getOwner()
long
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 sizeorg.apache.activemq.artemis.core.persistence.Persister<Message>
int
byte
Returns the message priority.Returns all the names of the properties for this message.int
default RoutingType
Used to calculate what is the delivery time.getShortProperty
(String key) default String
getStringProperty
(String key) long
default byte
getType()
Deprecated.do not use this, use through ICoreMessage or ClientMessageint
getUsage()
getUserContext
(Object key) Used for user context data.This represents historically the JMSMessageID.default String
default long
Return an estimate of the size of the message on the wire.default boolean
Search for the existence of the property: an implementor can save the message to be decoded, if possible.boolean
Returns whether this message is durable or not.default boolean
Returns whether this message is expired or not.default boolean
boolean
isPaged()
void
WARNING: Calling this method on a AMQPMessage will allow the non mutable part of the message to be modified.void
persist
(ActiveMQBuffer targetRecord) putBooleanProperty
(String key, boolean value) Callers must callreencode()
in order to be sent to clientsputBooleanProperty
(SimpleString key, boolean value) Callers must callreencode()
in order to be sent to clientsputByteProperty
(String key, byte value) Callers must callreencode()
in order to be sent to clientsputByteProperty
(SimpleString key, byte value) Callers must callreencode()
in order to be sent to clientsputBytesProperty
(String key, byte[] value) Callers must callreencode()
in order to be sent to clientsputBytesProperty
(SimpleString key, byte[] value) Callers must callreencode()
in order to be sent to clientsputCharProperty
(String key, char value) Callers must callreencode()
in order to be sent to clientsputCharProperty
(SimpleString key, char value) Callers must callreencode()
in order to be sent to clientsputDoubleProperty
(String key, double value) Callers must callreencode()
in order to be sent to clientsputDoubleProperty
(SimpleString key, double value) Callers must callreencode()
in order to be sent to clientsdefault Message
putExtraBytesProperty
(SimpleString key, byte[] value) putFloatProperty
(String key, float value) Callers must callreencode()
in order to be sent to clientsputFloatProperty
(SimpleString key, float value) Callers must callreencode()
in order to be sent to clientsputIntProperty
(String key, int value) Callers must callreencode()
in order to be sent to clientsputIntProperty
(SimpleString key, int value) Callers must callreencode()
in order to be sent to clientsputLongProperty
(String key, long value) Callers must callreencode()
in order to be sent to clientsputLongProperty
(SimpleString key, long value) Callers must callreencode()
in order to be sent to clientsputObjectProperty
(String key, Object value) Callers must callreencode()
in order to be sent to clientsputObjectProperty
(SimpleString key, Object value) Callers must callreencode()
in order to be sent to clientsputShortProperty
(String key, short value) Callers must callreencode()
in order to be sent to clientsputShortProperty
(SimpleString key, short value) Callers must callreencode()
in order to be sent to clientsputStringProperty
(String key, String value) Puts a String property in this message.putStringProperty
(SimpleString key, String value) putStringProperty
(SimpleString key, SimpleString value) void
receiveBuffer
(io.netty.buffer.ByteBuf buffer) Used to receive this message from an encoded medium bufferdefault void
reencode()
Propagate message modifications to clients.int
refDown()
default void
referenceOriginalMessage
(Message original, SimpleString originalQueue) int
refUp()
default void
rejectConsumer
(long uniqueConsumerID) void
reloadPersistence
(ActiveMQBuffer record, org.apache.activemq.artemis.core.persistence.CoreMessageObjectPools pools) default Object
default byte[]
removeProperty
(String key) void
sendBuffer
(io.netty.buffer.ByteBuf buffer, int deliveryCount) Used to send this message to an encoded medium buffer.setAddress
(String address) Look atsetAddress(SimpleString)
for the doc.setAddress
(SimpleString address) This will set the address on CoreMessage.default Message
setAnnotation
(SimpleString key, Object value) Callers must callreencode()
in order to be sent to clientsdefault Message
setBrokerProperty
(SimpleString key, Object value) To be called by the broker on ocasions such as DLQ and expiry.default Message
setConnectionID
(String connectionID) default Message
setCorrelationID
(Object correlationID) setDurable
(boolean durable) Sets whether this message is durable or not.setExpiration
(long expiration) Sets the expiration of this message.default Message
setGroupID
(String groupID) default Message
setGroupID
(SimpleString groupID) default Message
setGroupSequence
(int sequence) default Message
default Message
setLastValueProperty
(SimpleString lastValueName) setMessageID
(long id) void
void
setPaged()
setPriority
(byte priority) Sets the message priority.setReplyTo
(SimpleString address) default Message
setRoutingType
(RoutingType routingType) default Message
setScheduledDeliveryTime
(Long time) setTimestamp
(long timestamp) default Message
setType
(byte type) Deprecated.do not use this, use through ICoreMessage or ClientMessagevoid
setUserContext
(Object key, Object value) Used for user context data.default Message
setValidatedUserID
(String validatedUserID) default CompositeData
toCompositeData
(int fieldsLimit, int deliveryCount) toCore()
This should make you convert your message into Core format.toCore
(org.apache.activemq.artemis.core.persistence.CoreMessageObjectPools coreMessageObjectPools) This should make you convert your message into Core format.toMap()
toMap
(int valueSizeLimit) toPropertyMap
(int valueSizeLimit) int
int
usageUp()
this method indicates usage by components such as large message or page cache.
-
Field Details
-
memoryOffset
static final int memoryOffset- See Also:
-
PREFIX_AMQP_ANNOTATIONS
-
INTERNAL_PROPERTY_NAMES_PREDICATE
-
AMQP_PROPERTY_PREDICATE
-
HDR_ROUTE_TO_IDS
-
HDR_SCALEDOWN_TO_IDS
-
HDR_ROUTE_TO_ACK_IDS
-
HDR_BRIDGE_DUPLICATE_ID
-
HDR_ACTUAL_EXPIRY_TIME
the actual time the message was expired. * * -
HDR_ORIGINAL_ADDRESS
The original address of a message when a message is diverted or transferred through DLQ or expiry -
HDR_ORIGINAL_QUEUE
The original address of a message when a message is transferred through DLQ or expiry -
HDR_ORIG_MESSAGE_ID
The original message ID before the message was transferred. -
HDR_GROUP_ID
For the Message Grouping feature. -
HDR_GROUP_SEQUENCE
-
HDR_LARGE_COMPRESSED
to determine if the Large Message was compressed. -
HDR_LARGE_BODY_SIZE
The body size of a large message before it was compressed. -
HDR_SCHEDULED_DELIVERY_TIME
To be used with Scheduled Delivery. -
HDR_DUPLICATE_DETECTION_ID
To be used with duplicate detection. -
HDR_LAST_VALUE_NAME
To be used with Last value queues. -
HDR_CONTENT_TYPE
To define the mime-type of body messages. Mainly for stomp but it could be informed on any message for user purposes. -
HDR_VALIDATED_USER
The name of the validated user who sent the message. Useful for auditing. -
HDR_ROUTING_TYPE
The Routing Type for this message. Ensures that this message is only routed to queues with matching routing type. -
HDR_ORIG_ROUTING_TYPE
The original routing type of a message before getting transferred through DLQ or expiry -
HDR_INGRESS_TIMESTAMP
The time at which the message arrived at the broker. -
HDR_PREFIX
The prefix used (if any) when sending this message. For protocols (e.g. STOMP) that need to track this and restore the prefix when the message is consumed. -
DEFAULT_TYPE
static final byte DEFAULT_TYPE- See Also:
-
OBJECT_TYPE
static final byte OBJECT_TYPE- See Also:
-
TEXT_TYPE
static final byte TEXT_TYPE- See Also:
-
BYTES_TYPE
static final byte BYTES_TYPE- See Also:
-
MAP_TYPE
static final byte MAP_TYPE- See Also:
-
STREAM_TYPE
static final byte STREAM_TYPE- See Also:
-
EMBEDDED_TYPE
static final byte EMBEDDED_TYPEThe message will contain another message persisted through org.apache.activemq.artemis.spi.core.protocol.EmbedMessageUtil- See Also:
-
LARGE_EMBEDDED_TYPE
static final byte LARGE_EMBEDDED_TYPEThis is to embedd Large Messages from other protocol- See Also:
-
-
Method Details
-
clearInternalProperties
default void clearInternalProperties() -
clearAMQPProperties
default void clearAMQPProperties() -
hasScheduledDeliveryTime
default boolean hasScheduledDeliveryTime()Search for the existence of the property: an implementor can save the message to be decoded, if possible. -
getRoutingType
-
setRoutingType
-
getLastValueProperty
-
setLastValueProperty
-
getBodyInputStream
Deprecated.do not use this, use through ICoreMessage or ClientMessage -
getBodyBuffer
Deprecated.do not use this, use through ICoreMessage or ClientMessage Warning: if you need to read the content of a message use getDataBuffer(). This method is intended for when you want to make changes. -
getType
Deprecated.do not use this, use through ICoreMessage or ClientMessage -
setType
Deprecated.do not use this, use through ICoreMessage or ClientMessage -
messageChanged
void messageChanged()WARNING: Calling this method on a AMQPMessage will allow the non mutable part of the message to be modified. -
getScheduledDeliveryTime
Long getScheduledDeliveryTime()Used to calculate what is the delivery time. Return null if not scheduled. -
setPaged
void setPaged() -
isPaged
boolean isPaged() -
setScheduledDeliveryTime
-
getGroupID
-
setGroupID
-
setGroupID
-
getGroupSequence
default int getGroupSequence() -
setGroupSequence
-
getCorrelationID
-
setCorrelationID
-
getReplyTo
SimpleString getReplyTo() -
setReplyTo
-
copy
Message copy()It will generate a new instance of the message encode, being a deep copy, new properties, new everything -
copy
It will generate a new instance of the message encode, being a deep copy, new properties, new everything -
copy
It will generate a new instance of the message encode, being a deep copy, new properties, new everything -
acceptsConsumer
default boolean acceptsConsumer(long uniqueConsumerID) -
rejectConsumer
default void rejectConsumer(long uniqueConsumerID) -
getMessageID
long getMessageID()Returns the messageID.
The messageID is set when the message is handled by the server. -
getProtocolName
String getProtocolName() -
setConnectionID
-
getConnectionID
-
setMessageID
-
isLargeMessage
default boolean isLargeMessage() -
getExpiration
long getExpiration()Returns the expiration time of this message. -
setExpiration
Sets the expiration of this message.- Parameters:
expiration
- expiration time
-
isExpired
default boolean isExpired()Returns whether this message is expired or not. -
getUserID
Object getUserID()This represents historically the JMSMessageID. We had in the past used this for the MessageID that was sent on core messages... later on when we added AMQP this name clashed with AMQPMessage.getUserID();- Returns:
- the user id
-
setUserID
-
getValidatedUserID
-
setValidatedUserID
-
isDurable
boolean isDurable()Returns whether this message is durable or not. -
setDurable
Sets whether this message is durable or not.- Parameters:
durable
-true
to flag this message as durable,false
else
-
getPersister
org.apache.activemq.artemis.core.persistence.Persister<Message> getPersister() -
getAddress
String getAddress() -
setAddress
Look atsetAddress(SimpleString)
for the doc.- Parameters:
address
-- Returns:
-
getAddressSimpleString
SimpleString getAddressSimpleString() -
setAddress
This will set the address on CoreMessage. Note for AMQPMessages: in AMQPMessages this will not really change the address on the message. Instead it will add a property on extraProperties which only transverse internally at the broker. Whatever you change here it won't affect anything towards the received message. If you wish to change AMQPMessages address you will have to do it directly at the AMQP Message, however beware that AMQPMessages are not supposed to be changed at the broker, so only do it if you know what you are doing.- Parameters:
address
-- Returns:
-
getTimestamp
long getTimestamp() -
setTimestamp
-
getPriority
byte getPriority()Returns the message priority.Values range from 0 (less priority) to 9 (more priority) inclusive.
-
setPriority
Sets the message priority.Value must be between 0 and 9 inclusive.
- Parameters:
priority
- the new message priority
-
receiveBuffer
void receiveBuffer(io.netty.buffer.ByteBuf buffer) Used to receive this message from an encoded medium buffer -
sendBuffer
void sendBuffer(io.netty.buffer.ByteBuf buffer, int deliveryCount) Used to send this message to an encoded medium buffer.- Parameters:
buffer
- the buffer used.deliveryCount
- Some protocols (AMQP) will have this as part of the message.
-
getPersistSize
int getPersistSize() -
persist
-
reloadPersistence
void reloadPersistence(ActiveMQBuffer record, org.apache.activemq.artemis.core.persistence.CoreMessageObjectPools pools) -
reencode
default void reencode()Propagate message modifications to clients. -
referenceOriginalMessage
-
getDuplicateIDBytes
default byte[] getDuplicateIDBytes()it will translate a property named HDR_DUPLICATE_DETECTION_ID.- Returns:
-
putExtraBytesProperty
-
getExtraBytesProperty
-
removeExtraBytesProperty
default byte[] removeExtraBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException -
getDuplicateProperty
-
putBooleanProperty
Callers must callreencode()
in order to be sent to clients -
putByteProperty
Callers must callreencode()
in order to be sent to clients -
putBytesProperty
Callers must callreencode()
in order to be sent to clients -
putShortProperty
Callers must callreencode()
in order to be sent to clients -
putCharProperty
Callers must callreencode()
in order to be sent to clients -
putIntProperty
Callers must callreencode()
in order to be sent to clients -
putLongProperty
Callers must callreencode()
in order to be sent to clients -
putFloatProperty
Callers must callreencode()
in order to be sent to clients -
putDoubleProperty
Callers must callreencode()
in order to be sent to clients -
putBooleanProperty
Callers must callreencode()
in order to be sent to clients -
putByteProperty
Callers must callreencode()
in order to be sent to clients -
putBytesProperty
Callers must callreencode()
in order to be sent to clients -
putShortProperty
Callers must callreencode()
in order to be sent to clients -
putCharProperty
Callers must callreencode()
in order to be sent to clients -
putIntProperty
Callers must callreencode()
in order to be sent to clients -
putLongProperty
Callers must callreencode()
in order to be sent to clients -
putFloatProperty
Callers must callreencode()
in order to be sent to clients -
putDoubleProperty
Callers must callreencode()
in order to be sent to clients -
putStringProperty
Puts a String property in this message.Callers must call
reencode()
in order to be sent to clients- Parameters:
key
- property namevalue
- property value
-
putObjectProperty
Callers must callreencode()
in order to be sent to clients -
putObjectProperty
Message putObjectProperty(SimpleString key, Object value) throws ActiveMQPropertyConversionException Callers must callreencode()
in order to be sent to clients -
removeProperty
-
containsProperty
-
getBooleanProperty
-
getByteProperty
-
getDoubleProperty
-
getIntProperty
-
getLongProperty
-
getObjectProperty
-
getShortProperty
-
getFloatProperty
-
getStringProperty
-
getSimpleStringProperty
-
getBytesProperty
-
removeProperty
-
containsProperty
-
getBooleanProperty
-
getByteProperty
-
getDoubleProperty
-
getIntProperty
-
getLongProperty
-
getObjectPropertyForFilter
-
getObjectProperty
-
removeAnnotation
-
getAnnotationString
-
getAnnotation
-
setAnnotation
Callers must callreencode()
in order to be sent to clients -
setBrokerProperty
To be called by the broker on ocasions such as DLQ and expiry. When the broker is adding additional properties. -
getBrokerProperty
-
setIngressTimestamp
-
getIngressTimestamp
-
getShortProperty
-
getFloatProperty
-
getStringProperty
-
getSimpleStringProperty
-
getBytesProperty
-
putStringProperty
-
putStringProperty
-
getEncodeSize
int getEncodeSize()Returns the size of the encoded message. -
getWholeMessageSize
default long getWholeMessageSize()Return an estimate of the size of the message on the wire. for LargeMessages this will contain whatever is needed to encode properties and the body size of large messages. For AMQP this will return the whole body size of the message as the body will contain all the data including properties.- Returns:
-
getPropertyNames
Set<SimpleString> getPropertyNames()Returns all the names of the properties for this message. -
getRefCount
int getRefCount() -
getUsage
int getUsage() -
getDurableCount
int getDurableCount() -
usageUp
int usageUp()this method indicates usage by components such as large message or page cache. This method will cause large messages to be held longer after the ack happened for instance. -
usageDown
int usageDown()- Returns:
- See Also:
-
refUp
int refUp() -
refDown
int refDown() -
durableUp
int durableUp() -
durableDown
int durableDown() -
toMap
- Returns:
- Returns the message in Map form, useful when encoding to JSON
-
toMap
- Parameters:
valueSizeLimit
- that limits [] map values- Returns:
- Returns the message in Map form, useful when encoding to JSON
-
toPropertyMap
- Returns:
- Returns the message properties in Map form, useful when encoding to JSON
-
toPropertyMap
- Parameters:
valueSizeLimit
- that limits [] map values- Returns:
- Returns the message properties in Map form, useful when encoding to JSON
-
toCore
ICoreMessage toCore()This should make you convert your message into Core format. -
toCompositeData
- Throws:
OpenDataException
-
toCore
ICoreMessage toCore(org.apache.activemq.artemis.core.persistence.CoreMessageObjectPools coreMessageObjectPools) This should make you convert your message into Core format. -
getMemoryEstimate
int getMemoryEstimate() -
getOriginalEstimate
default int getOriginalEstimate()The first estimate that's been calculated without any updates. -
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- Returns:
- Throws:
ActiveMQException
-
getOwner
Object getOwner() -
setOwner
-
getStringBody
-
getUserContext
Used for user context data. Useful on interceptors. -
setUserContext
Used for user context data. Useful on interceptors.
-