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 bytestatic final bytestatic final byteThe message will contain another message persisted throughorg.apache.activemq.artemis.spi.core.protocol.EmbedMessageUtilstatic final SimpleStringthe actual time the message was expired. * *static final SimpleStringstatic final SimpleStringTo define the mime-type of body messages.static final SimpleStringTo be used with duplicate detection.static final SimpleStringFor the Message Grouping feature.static final SimpleStringstatic final SimpleStringThe time at which the message arrived at the broker.static final SimpleStringThe body size of a large message before it was compressed.static final SimpleStringto determine if the Large Message was compressed.static final SimpleStringTo be used with Last value queues.static final SimpleStringThe original message ID before the message was transferred.static final SimpleStringThe original routing type of a message before getting transferred through DLQ or expirystatic final SimpleStringThe original address of a message when a message is diverted or transferred through DLQ or expirystatic final SimpleStringThe original address of a message when a message is transferred through DLQ or expirystatic final SimpleStringThe prefix used (if any) when sending this message.static final SimpleStringstatic final SimpleStringstatic final SimpleStringThe Routing Type for this message.static final SimpleStringstatic final SimpleStringTo be used with Scheduled Delivery.static final SimpleStringThe name of the validated user who sent the message.static final Predicate<SimpleString> static final byteThis is to embedd Large Messages from other protocolstatic final bytestatic final intstatic final bytestatic final SimpleStringstatic final bytestatic final byte -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanacceptsConsumer(long uniqueConsumerID) default voiddefault voidbooleancontainsProperty(String key) booleancopy()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 Messagecopy(long newID, boolean isExpiryOrDLQ) It will generate a new instance of the message encode, being a deep copy, new properties, new everythingintintdefault Stringdefault ActiveMQBufferDeprecated.do not use this, use through ICoreMessage or ClientMessage Warning: if you need to read the content of a message use getDataBuffer().default InputStreamDeprecated.do not use this, use through ICoreMessage or ClientMessagegetBooleanProperty(String key) default ObjectgetByteProperty(String key) byte[]getBytesProperty(String key) byte[]default Stringdefault ObjectgetDoubleProperty(String key) default byte[]it will translate a property named HDR_DUPLICATE_DETECTION_ID.default ObjectintintReturns the size of the encoded message.longReturns the expiration time of this message.default byte[]getFloatProperty(String key) default SimpleStringdefault intdefault LonggetIntProperty(String key) default SimpleStringgetLongProperty(String key) intlongReturns the messageID; the messageID is set when the message is handled by the server.getObjectProperty(String key) default Objectdefault intThe first estimate that's been calculated without any updates.getOwner()longThis 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> intbyteReturns the message priority; values range from 0 (less priority) to 9 (more priority) inclusive.Returns all the names of the properties for this message.intdefault RoutingTypeUsed to calculate what is the delivery time.getShortProperty(String key) default StringgetStringProperty(String key) longdefault bytegetType()Deprecated.do not use this, use through ICoreMessage or ClientMessageintgetUsage()getUserContext(Object key) Used for user context data.This represents historically the JMSMessageID.default Stringdefault longReturn 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.default booleanSearch for the existence of the property: an implementor can save the message to be decoded, if possible.booleanReturns whether this message is durable or not.default booleanReturns whether this message is expired or not.default booleanbooleanisPaged()voidWARNING: Calling this method on a AMQPMessage will allow the non mutable part of the message to be modified.voidpersist(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 MessageputExtraBytesProperty(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) voidreceiveBuffer(io.netty.buffer.ByteBuf buffer) Used to receive this message from an encoded medium bufferdefault voidreencode()Propagate message modifications to clients.intrefDown()default voidreferenceOriginalMessage(Message original, SimpleString originalQueue) intrefUp()default voidrejectConsumer(long uniqueConsumerID) voidreloadPersistence(ActiveMQBuffer record, org.apache.activemq.artemis.core.persistence.CoreMessageObjectPools pools) default Objectdefault byte[]removeProperty(String key) default voidrouted()voidsendBuffer(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 MessagesetAnnotation(SimpleString key, Object value) Callers must callreencode()in order to be sent to clientsdefault MessagesetBrokerProperty(SimpleString key, Object value) To be called by the broker on ocasions such as DLQ and expiry.default MessagesetConnectionID(String connectionID) default MessagesetCorrelationID(Object correlationID) setDurable(boolean durable) Sets whether this message is durable or not.setExpiration(long expiration) Sets the expiration of this message.default MessagesetGroupID(String groupID) default MessagesetGroupID(SimpleString groupID) default MessagesetGroupSequence(int sequence) default Messagedefault MessagesetLastValueProperty(SimpleString lastValueName) setMessageID(long id) voidvoidsetPaged()setPriority(byte priority) Sets the message priority.setReplyTo(SimpleString address) default MessagesetRoutingType(RoutingType routingType) default MessagesetScheduledDeliveryTime(Long time) setTimestamp(long timestamp) default MessagesetType(byte type) Deprecated.do not use this, use through ICoreMessage or ClientMessagevoidsetUserContext(Object key, Object value) Used for user context data.default MessagesetValidatedUserID(String validatedUserID) default CompositeDatatoCompositeData(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()Returns Returns the message in Map form, useful when encoding to JSON.toMap(int valueSizeLimit) Returns the message in Map form, useful when encoding to JSON.Returns Returns the message properties in Map form, useful when encoding to JSON.toPropertyMap(int valueSizeLimit) Returns Returns the message properties in Map form, useful when encoding to JSON.intOpposite ofusageUp()intusageUp()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 throughorg.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.- 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.- 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.- 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.- Returns:
- whether this message is durable or not
-
setDurable
Sets whether this message is durable or not.- Parameters:
durable-trueto flag this message as durable,falseelse
-
getPersister
org.apache.activemq.artemis.core.persistence.Persister<Message> getPersister() -
getAddress
String getAddress() -
setAddress
Look atsetAddress(SimpleString)for the doc. -
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.
-
getTimestamp
long getTimestamp() -
setTimestamp
-
getPriority
byte getPriority()Returns the message priority; values range from 0 (less priority) to 9 (more priority) inclusive.- 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. -
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.- 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. -
getPropertyNames
Set<SimpleString> getPropertyNames()Returns all the names of the properties for this message.- 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
-
refUp
int refUp() -
refDown
int refDown() -
durableUp
int durableUp() -
durableDown
int durableDown() -
routed
default void routed() -
toMap
-
toMap
-
toPropertyMap
-
toPropertyMap
-
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- Throws:
ActiveMQException
-
getOwner
Object getOwner() -
setOwner
-
getStringBody
-
getUserContext
-
setUserContext
-