Interface Message
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFunctional interface for converting a single AMQP body section value.static interfaceMessageAddressBuilder.static interfaceFunctional interface for converting multiple AMQP body section values. -
Method Summary
Modifier and TypeMethodDescriptionlongGet the expiry time.absoluteExpiryTime(long absoluteExpiryTime) Set the expiry time.annotation(String key) Get the value of a message annotation.annotation(String key, Object value) Set the value of a message annotation.byte[]body()Get the message body as bytes.body(byte[] body) Set the body of the message.<I,O> O body(Message.Converter<I, O> converter) Get the message body converted using the specified converter.<I,O> O body(Message.SectionsConverter<I, O> converter) Get the message body with access to all body sections using the specified sections converter.Get the content-encoding.contentEncoding(String contentEncoding) Set the content-encoding.Get the content-type.contentType(String contentType) Set the content-type.Get message correlation ID.correlationId(byte[] correlationId) Set the message correlation ID (array of bytes).correlationId(long correlationId) Set the message correlation ID (long).correlationId(Object correlationId) Set the message correlation ID.correlationId(String correlationId) Set the message correlation ID (string).correlationId(UUID correlationId) Set the message correlation ID (UUID).byte[]Get message correlation ID as an array of bytes.longGet message correlation ID as a long.Get message correlation ID as a string.Get message correlation ID as a UUID.longGet the creation time.creationTime(long creationTime) Set the creation time.longGet the delivery count of the message.booleandurable()Whether the message is durable.durable(boolean durable) Mark the message as durable or not.booleanWhether the message may have been acquired by another link.forEachAnnotation(BiConsumer<String, Object> action) Iterate over message annotations.forEachProperty(BiConsumer<String, Object> action) Iterate over application properties.groupId()Get the group ID.Set the group ID.intGet the message position in its group.groupSequence(int groupSequence) Set the position of the message in its group.booleanhasAnnotation(String key) Whether a message annotation is set.booleanWhether the message has message annotation.booleanWhether at least one application property is set on the message.booleanhasProperty(String key) Check an application property is set.Get message ID.messageId(byte[] id) Set the message ID (array of bytes).messageId(long id) Set the message ID (long).Set the message ID.Set the message ID (string).Set the message ID (UUID).byte[]Get message ID as an array of bytes.longGet message ID as a long.Get message ID as a string.Get message ID as a UUID.bytepriority()Get the message priority.priority(byte priority) Set the priority of the message.Get the value of an application property.Set an application property.Set an application property.Set an application property.Set an application property.Set an application property.Set an application property.Set an application property.Set an application property.Set an application property.Set an application property.Set an application property.propertyDecimal128(String key, BigDecimal value) Set an application property.propertyDecimal32(String key, BigDecimal value) Set an application property.propertyDecimal64(String key, BigDecimal value) Set an application property.propertySymbol(String key, String value) Set an application property.propertyTimestamp(String key, long value) Set an application property.propertyUnsigned(String key, byte value) Set an application property.propertyUnsigned(String key, int value) Set an application property.propertyUnsigned(String key, long value) Set an application property.propertyUnsigned(String key, short value) Set an application property.removeAnnotation(String key) Remove an annotation.removeProperty(String key) Remove an application property.replyTo()Get the reply-to field.Set the reply-to field.AddressBuilderfor thereplyTo()field.Get the reply-to group ID.replyToGroupId(String groupId) Set the reply-to group ID.subject()Get the subject.Set the message subject.to()Get the to field.Set the to field.AddressBuilderfor theto()field.ttl()Get the message TTL.Set the message TTL.byte[]userId()Get user IDuserId(byte[] userId) Set the user ID.
-
Method Details
-
messageId
-
messageIdAsString
-
messageIdAsLong
long messageIdAsLong()Get message ID as a long.- Returns:
- the message ID as a long
-
messageIdAsBinary
byte[] messageIdAsBinary()Get message ID as an array of bytes.- Returns:
- the message ID as an array of bytes
-
messageIdAsUuid
-
correlationId
-
correlationIdAsString
String correlationIdAsString()Get message correlation ID as a string.- Returns:
- the message correlation ID as a string
-
correlationIdAsLong
long correlationIdAsLong()Get message correlation ID as a long.- Returns:
- the message correlation ID as a long
-
correlationIdAsBinary
byte[] correlationIdAsBinary()Get message correlation ID as an array of bytes.- Returns:
- the message correlation ID as an array of bytes
-
correlationIdAsUuid
UUID correlationIdAsUuid()Get message correlation ID as a UUID.- Returns:
- the message correlation ID as a UUID
-
userId
byte[] userId()Get user ID- Returns:
- the user ID
-
to
-
subject
-
replyTo
-
messageId
-
messageId
-
messageId
Set the message ID (long).- Parameters:
id- message ID- Returns:
- the message
-
messageId
Set the message ID (array of bytes).- Parameters:
id- message ID- Returns:
- the message
-
messageId
-
correlationId
-
correlationId
-
correlationId
Set the message correlation ID (long).- Parameters:
correlationId- correlation ID- Returns:
- the message
-
correlationId
Set the message correlation ID (array of bytes).- Parameters:
correlationId- correlation ID- Returns:
- the message
-
correlationId
-
userId
-
to
Set the to field.Prefer using
toAddress()to build the target address.- Parameters:
address- to address- Returns:
- the message
- See Also:
-
subject
-
replyTo
Set the reply-to field.Prefer using
replyToAddress()to build the reply-to address.- Parameters:
replyTo- reply-to field- Returns:
- the message
- See Also:
-
contentType
-
contentEncoding
-
absoluteExpiryTime
Set the expiry time.- Parameters:
absoluteExpiryTime- expiry time- Returns:
- the message
-
creationTime
Set the creation time.- Parameters:
creationTime- creation time- Returns:
- the message
-
groupId
-
groupSequence
Set the position of the message in its group.- Parameters:
groupSequence- group sequence- Returns:
- the message
-
replyToGroupId
-
contentType
-
contentEncoding
-
absoluteExpiryTime
long absoluteExpiryTime()Get the expiry time.- Returns:
- the expiry time
-
creationTime
long creationTime()Get the creation time.- Returns:
- the creation time
-
groupId
-
groupSequence
int groupSequence()Get the message position in its group.- Returns:
- the group sequence
-
replyToGroupId
-
property
-
property
-
property
-
property
-
property
-
property
-
propertyUnsigned
-
propertyUnsigned
-
propertyUnsigned
-
propertyUnsigned
-
property
-
property
-
propertyDecimal32
Set an application property.- Parameters:
key- property keyvalue- property value- Returns:
- the message
-
propertyDecimal64
Set an application property.- Parameters:
key- property keyvalue- property value- Returns:
- the message
-
propertyDecimal128
Set an application property.- Parameters:
key- property keyvalue- property value- Returns:
- the message
-
property
-
propertyTimestamp
-
property
-
property
-
property
-
propertySymbol
-
hasProperty
Check an application property is set.- Parameters:
key- property name- Returns:
- true if set, false otherwise
-
hasProperties
boolean hasProperties()Whether at least one application property is set on the message.- Returns:
- true if the message has at least one application property, false otherwise
-
removeProperty
-
forEachProperty
Iterate over application properties.- Parameters:
action- action to execute for each application property- Returns:
- the message
-
body
Set the body of the message.- Parameters:
body- message body- Returns:
- the message
-
body
byte[] body()Get the message body as bytes.This is a convenience API for byte-oriented payload access. It is intended for message bodies that can be represented as a byte array, such as Data sections and compatible AmqpValue payloads (for example String values converted to UTF-8 bytes).
For AMQP body types that are not naturally byte-oriented, such as AmqpSequence or typed AmqpValue payloads, use
body(Converter)orbody(SectionsConverter).- Returns:
- the message body as bytes
- Throws:
AmqpException- if the body cannot be represented as bytes
-
body
Get the message body converted using the specified converter.This method provides access to the message body content in its native AMQP 1.0 format, allowing applications to handle non-binary payloads and complex message body structures. According to the AMQP 1.0 message format specification, a message body can contain various section types including AmqpValue, AmqpSequence, and Data sections.
This method extracts the value from the first body section only and passes it to the converter. For messages with multiple body sections, use
body(SectionsConverter)instead.The converter input type must match the runtime type of the value exposed by the underlying AMQP implementation for the first body section. For example, applications may receive
byte[],String,List<?>, or implementation-specific AMQP types such asBinary.If the converter expects a type that does not match the runtime body value type, a
ClassCastExceptionmay be thrown by the converter invocation.Implementation Note: This method exposes values coming from the underlying AMQP implementation (currently Qpid Proton-J2). Applications using this API should treat these values as implementation-coupled runtime types rather than stable library-defined model types. Changes in the underlying implementation may affect the concrete runtime types observed by applications using this API.
- Type Parameters:
I- the input type expected by the converter (the type of the body section value)O- the output type returned by the converter- Parameters:
converter- the converter to transform the body section value- Returns:
- the converted body value
- Throws:
AmqpException- if an error occurs while accessing the message body- See Also:
-
body
Get the message body with access to all body sections using the specified sections converter.This method provides complete access to multi-section message bodies as defined in the AMQP 1.0 message format specification. AMQP 1.0 messages can contain multiple body sections of the same type:
- Multiple Data sections - Each containing binary data, typically concatenated logically
- Multiple AmqpSequence sections - Each containing a list of structured values
- Single AmqpValue section - Containing a single AMQP value of any type
The converter receives a list of all section values from the message body, allowing applications to process complex multi-section payloads that cannot be handled by the single-section
body(Converter)method.The converter input type must match the runtime type of each section value exposed by the underlying AMQP implementation. All body sections in a valid AMQP message are expected to be of the same section kind, but applications should still treat the values as implementation exposed runtime objects.
If the converter expects a type that does not match the runtime section value type, a
ClassCastExceptionmay be thrown by the converter invocation.Implementation Note: This method exposes values coming from the underlying AMQP implementation (currently Qpid Proton-J2). Applications using this API should treat these values as implementation-coupled runtime types rather than stable library-defined model types. Changes in the underlying implementation may affect the concrete runtime types observed by applications using this API.
- Type Parameters:
I- the input type expected by the converter (the type of each body section value)O- the output type returned by the converter- Parameters:
converter- the sections converter to transform all body section values- Returns:
- the converted body value from all sections
- Throws:
AmqpException- if an error occurs while accessing the message body sections- See Also:
-
durable
Mark the message as durable or not.Messages are durable by default, use
falseto make them explicitly non-durable.Durability depends also on the queue messages end up in (e.g. quorum queues and streams always store messages durably).
- Parameters:
durable- true for a durable message, false for a non-durable message- Returns:
- the message
-
durable
boolean durable()Whether the message is durable.- Returns:
- true if durable, false otherwise
- See Also:
-
deliveryCount
long deliveryCount()Get the delivery count of the message.The delivery count tracks the number of failed delivery attempts for the message. This value is incremented when a delivery fails (e.g., consumer crashes, message is rejected, or AMQP 1.0
modifydisposition withdelivery_failed=true). It is not incremented for successful requeues (e.g.,nackor AMQP 1.0modifywithdelivery_failed=false).- Returns:
- the delivery count
- Since:
- 1.1.0
- See Also:
-
priority
Set the priority of the message.- Parameters:
priority- message priority- Returns:
- the message
- See Also:
-
priority
byte priority()Get the message priority.- Returns:
- the message priority
- See Also:
-
ttl
-
ttl
-
firstAcquirer
boolean firstAcquirer()Whether the message may have been acquired by another link.- Returns:
- true if the message has not been acquired by another link, false if it may have been already acquired by another link
- See Also:
-
annotation
-
annotation
-
hasAnnotation
Whether a message annotation is set.- Parameters:
key- annotation key- Returns:
- true if the annotation is set, false otherwise
- See Also:
-
hasAnnotations
boolean hasAnnotations()Whether the message has message annotation.- Returns:
- true if the message has annotations, false otherwise
- See Also:
-
removeAnnotation
-
forEachAnnotation
Iterate over message annotations.- Parameters:
action- action to execute for each message annotation- Returns:
- the message
-
toAddress
Message.MessageAddressBuilder toAddress()AddressBuilderfor theto()field.- Returns:
- the address builder
-
replyToAddress
Message.MessageAddressBuilder replyToAddress()AddressBuilderfor thereplyTo()field.- Returns:
- the address builder
-