Class ClientMessage<E>
- java.lang.Object
-
- org.apache.qpid.protonj2.client.impl.ClientMessage<E>
-
- Type Parameters:
E- the body type that theMessagecarries
- All Implemented Interfaces:
AdvancedMessage<E>,Message<E>
public final class ClientMessage<E> extends java.lang.Object implements AdvancedMessage<E>
Client providedAdvancedMessageimplementation that is used when sending messages from aClientSenderor when decoding an AMQP Transfer for which all frames have arrived.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longabsoluteExpiryTime()Message<E>absoluteExpiryTime(long expiryTime)Sets the absolute expiration time value to assign to thisMessage.ClientMessage<E>addBodySection(Section<?> bodySection)Adds the givenSectionto the internal collection of sections that will be sent to the remote peer when this message is encoded.java.lang.Objectannotation(java.lang.String key)Returns the requested message annotation value from thisMessageif it exists or returns null otherwise.ClientMessage<E>annotation(java.lang.String key, java.lang.Object value)Sets the given message annotation value at the given key, replacing any previous value that was assigned to thisMessage.MessageAnnotationsannotations()Return the currentMessageAnnotationsassigned to this message, if none was assigned yet then this method returnsnull.ClientMessage<E>annotations(MessageAnnotations messageAnnotations)Assign or replace theMessageAnnotationsinstance associated with this message.ApplicationPropertiesapplicationProperties()Return the currentApplicationPropertiesassigned to this message, if none was assigned yet then this method returnsnull.ClientMessage<E>applicationProperties(ApplicationProperties applicationProperties)Assign or replace theApplicationPropertiesinstance associated with this message.Ebody()Returns the body value that is conveyed in this message or null if no body was set locally or sent from the remote if this is an incoming message.ClientMessage<E>body(E value)Sets the body value that is to be conveyed to the remote when this message is sent.java.util.Collection<Section<?>>bodySections()Create and return an unmodifiableCollectionthat contains theSectioninstances currently assigned to this message.ClientMessage<E>bodySections(java.util.Collection<Section<?>> sections)Sets the bodySectioninstances to use when encoding this message.ClientMessage<E>clearBodySections()Clears all current bodySectionelements from theAdvancedMessage.java.lang.StringcontentEncoding()Message<E>contentEncoding(java.lang.String contentEncoding)Sets the contentEncoding value to assign to thisMessage.java.lang.StringcontentType()Message<E>contentType(java.lang.String contentType)Sets the contentType value to assign to thisMessage.java.lang.ObjectcorrelationId()Message<E>correlationId(java.lang.Object correlationId)Sets the correlationId value to assign to thisMessage.static <V> ClientMessage<V>create()Creates an emptyClientMessageinstance.static <V> ClientMessage<V>create(Section<V> body)Creates anClientMessageinstance with the given bodySectionvalue.static <V> ClientMessage<V>createAdvancedMessage()Creates an emptyClientMessageinstance.longcreationTime()Message<E>creationTime(long createTime)Sets the creation time value to assign to thisMessage.longdeliveryCount()ClientMessage<E>deliveryCount(long deliveryCount)Sets the value to assign to the delivery count field of thisMessage.booleandurable()For an message being sent this method returns the current state of the durable flag on the message.ClientMessage<E>durable(boolean durable)Controls if the message is marked as durable when sent.ProtonBufferencode(java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations)Encodes theAdvancedMessagefor transmission by the client.booleanfirstAcquirer()ClientMessage<E>firstAcquirer(boolean firstAcquirer)Sets the value to assign to the first acquirer field of thisMessage.Footerfooter()Return the currentFooterassigned to this message, if none was assigned yet then this method returnsnull.java.lang.Objectfooter(java.lang.String key)Returns the requested footer value from thisMessageif it exists or returnsnullotherwise.ClientMessage<E>footer(java.lang.String key, java.lang.Object value)Sets the given footer value at the given key, replacing any previous value that was assigned to thisMessage.ClientMessage<E>footer(Footer footer)Assign or replace theFooterinstance associated with this message.Message<E>forEachAnnotation(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)Invokes the givenBiConsumeron each message annotation entry carried in thisMessage.ClientMessage<E>forEachBodySection(java.util.function.Consumer<Section<?>> consumer)Performs the given action for each bodySectionof theAdvancedMessageuntil all sections have been presented to the givenConsumeror the consumer throws an exception.Message<E>forEachFooter(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)Invokes the givenBiConsumeron each footer entry carried in thisMessage.Message<E>forEachProperty(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)Invokes the givenBiConsumeron each application property entry carried in thisMessage.java.lang.StringgroupId()Message<E>groupId(java.lang.String groupId)Sets the groupId value to assign to thisMessage.intgroupSequence()Message<E>groupSequence(int groupSequence)Sets the group sequence value to assign to thisMessage.booleanhasAnnotation(java.lang.String key)Query theMessageto determine if it carries the given message annotation key.booleanhasAnnotations()Query theMessageto determine if it carries any message annotations.booleanhasFooter(java.lang.String key)Query theMessageto determine if it carries the given footer key.booleanhasFooters()Query theMessageto determine if it carries any footers.booleanhasProperties()Query theMessageto determine if it carries any application properties.booleanhasProperty(java.lang.String key)Query theMessageto determine if it carries the given application property key.Headerheader()Return the currentHeaderassigned to this message, if none was assigned yet then this method returnsnull.ClientMessage<E>header(Header header)Assign or replace theHeaderinstance associated with this message.intmessageFormat()ClientMessage<E>messageFormat(int messageFormat)Sets the message format to use when the message is sent.java.lang.ObjectmessageId()Message<E>messageId(java.lang.Object messageId)Sets the message Id value to assign to thisMessage.bytepriority()ClientMessage<E>priority(byte priority)Sets the relative message priority.Propertiesproperties()Return the currentPropertiesassigned to this message, if none was assigned yet then this method returnsnull.ClientMessage<E>properties(Properties properties)Assign or replace thePropertiesinstance associated with this message.java.lang.Objectproperty(java.lang.String key)Returns the requested application property value from thisMessageif it exists or returns null otherwise.ClientMessage<E>property(java.lang.String key, java.lang.Object value)Sets the given application property value at the given key, replacing any previous value that was assigned to thisMessage.java.lang.ObjectremoveAnnotation(java.lang.String key)Removes the given message annotation from the values carried in the message currently, if none was present than this method returnsnull.java.lang.ObjectremoveFooter(java.lang.String key)Removes the given footer from the values carried in the message currently, if none was present than this method returnsnull.java.lang.ObjectremoveProperty(java.lang.String key)Removes the given application property from the values carried in the message currently, if none was present than this method returnsnull.java.lang.StringreplyTo()Message<E>replyTo(java.lang.String replyTo)Sets the replyTo value to assign to thisMessage.java.lang.StringreplyToGroupId()Message<E>replyToGroupId(java.lang.String replyToGroupId)Sets the replyTo group Id value to assign to thisMessage.java.lang.Stringsubject()Message<E>subject(java.lang.String subject)Sets the subject value to assign to thisMessage.longtimeToLive()ClientMessage<E>timeToLive(long timeToLive)Sets the message time to live value.java.lang.Stringto()Message<E>to(java.lang.String to)Sets the 'to' value to assign to thisMessage.AdvancedMessage<E>toAdvancedMessage()Safely convert thisMessageinstance into anAdvancedMessagereference which can offer more low level APIs to an experienced client user.byte[]userId()Message<E>userId(byte[] userId)Sets the user Id value to assign to thisMessage.
-
-
-
Method Detail
-
toAdvancedMessage
public AdvancedMessage<E> toAdvancedMessage()
Description copied from interface:MessageSafely convert thisMessageinstance into anAdvancedMessagereference which can offer more low level APIs to an experienced client user.The default implementation first checks if the current instance is already of the correct type before performing a brute force conversion of the current message to the client's own internal
AdvancedMessageimplementation. Users should override this method if the internal conversion implementation is insufficient to obtain the proper message structure to encode a meaningful 'on the wire' encoding of their custom implementation.- Specified by:
toAdvancedMessagein interfaceMessage<E>- Returns:
- a
AdvancedMessagethat contains this message's current state.
-
create
public static <V> ClientMessage<V> create()
Creates an emptyClientMessageinstance.- Type Parameters:
V- The type of the body value carried in this message.- Returns:
- a new empty
ClientMessageinstance.
-
create
public static <V> ClientMessage<V> create(Section<V> body)
Creates anClientMessageinstance with the given bodySectionvalue.- Type Parameters:
V- The type of the body value carried in this message body section.- Parameters:
body- The bodySectionto assign to the created message instance.- Returns:
- a new
ClientMessageinstance with the given body.
-
createAdvancedMessage
public static <V> ClientMessage<V> createAdvancedMessage()
Creates an emptyClientMessageinstance.- Type Parameters:
V- The type of the body value carried in this message.- Returns:
- a new empty
ClientMessageinstance.
-
durable
public boolean durable()
Description copied from interface:MessageFor an message being sent this method returns the current state of the durable flag on the message. For a received message this method returns the durable flag value at the time of sending (or false if not set) unless the value is updated after being received by the receiver.
-
durable
public ClientMessage<E> durable(boolean durable)
Description copied from interface:MessageControls if the message is marked as durable when sent.
-
priority
public byte priority()
-
priority
public ClientMessage<E> priority(byte priority)
Description copied from interface:MessageSets the relative message priority. Higher numbers indicate higher priority messages. Messages with higher priorities MAY be delivered before those with lower priorities. For a received message this overwrites any value that was set by the remote sender.
-
timeToLive
public long timeToLive()
- Specified by:
timeToLivein interfaceMessage<E>- Returns:
- the currently set Time To Live duration (milliseconds).
-
timeToLive
public ClientMessage<E> timeToLive(long timeToLive)
Description copied from interface:MessageSets the message time to live value.The time to live duration in milliseconds for which the message is to be considered "live". If this is set then a message expiration time will be computed based on the time of arrival at an intermediary. Messages that live longer than their expiration time will be discarded (or dead lettered). When a message is transmitted by an intermediary that was received with a time to live, the transmitted message's header SHOULD contain a time to live that is computed as the difference between the current time and the formerly computed message expiration time, i.e., the reduced time to live, so that messages will eventually die if they end up in a delivery loop.
- Specified by:
timeToLivein interfaceMessage<E>- Parameters:
timeToLive- The time span in milliseconds that this message should remain live before being discarded.- Returns:
- this
Messageinstance.
-
firstAcquirer
public boolean firstAcquirer()
- Specified by:
firstAcquirerin interfaceMessage<E>- Returns:
- if this message has been acquired by another link previously
-
firstAcquirer
public ClientMessage<E> firstAcquirer(boolean firstAcquirer)
Description copied from interface:MessageSets the value to assign to the first acquirer field of thisMessage.If this value is true, then this message has not been acquired by any other link. If this value is false, then this message MAY have previously been acquired by another link or links.
- Specified by:
firstAcquirerin interfaceMessage<E>- Parameters:
firstAcquirer- The boolean value to assign to the first acquirer field of the message.- Returns:
- this
Messageinstance.
-
deliveryCount
public long deliveryCount()
- Specified by:
deliveryCountin interfaceMessage<E>- Returns:
- the number of failed delivery attempts that this message has been part of.
-
deliveryCount
public ClientMessage<E> deliveryCount(long deliveryCount)
Description copied from interface:MessageSets the value to assign to the delivery count field of thisMessage.Delivery count is the number of unsuccessful previous attempts to deliver this message. If this value is non-zero it can be taken as an indication that the delivery might be a duplicate. On first delivery, the value is zero. It is incremented upon an outcome being settled at the sender, according to rules defined for each outcome.
- Specified by:
deliveryCountin interfaceMessage<E>- Parameters:
deliveryCount- The new delivery count value to assign to this message.- Returns:
- this
Messageinstance.
-
messageId
public java.lang.Object messageId()
-
messageId
public Message<E> messageId(java.lang.Object messageId)
Description copied from interface:MessageSets the message Id value to assign to thisMessage.The message Id, if set, uniquely identifies a message within the message system. The message producer is usually responsible for setting the message-id in such a way that it is assured to be globally unique. A remote peer MAY discard a message as a duplicate if the value of the message-id matches that of a previously received message sent to the same node.
-
userId
public byte[] userId()
-
userId
public Message<E> userId(byte[] userId)
Description copied from interface:MessageSets the user Id value to assign to thisMessage.The identity of the user responsible for producing the message. The client sets this value, and it MAY be authenticated by intermediaries.
-
to
public java.lang.String to()
-
to
public Message<E> to(java.lang.String to)
Description copied from interface:MessageSets the 'to' value to assign to thisMessage.The to field identifies the node that is the intended destination of the message. On any given transfer this might not be the node at the receiving end of the link.
-
subject
public java.lang.String subject()
-
subject
public Message<E> subject(java.lang.String subject)
Description copied from interface:MessageSets the subject value to assign to thisMessage.A common field for summary information about the message content and purpose.
-
replyTo
public java.lang.String replyTo()
-
replyTo
public Message<E> replyTo(java.lang.String replyTo)
Description copied from interface:MessageSets the replyTo value to assign to thisMessage.The address of the node to send replies to.
-
correlationId
public java.lang.Object correlationId()
- Specified by:
correlationIdin interfaceMessage<E>- Returns:
- the currently assigned correlation ID or null if none set.
-
correlationId
public Message<E> correlationId(java.lang.Object correlationId)
Description copied from interface:MessageSets the correlationId value to assign to thisMessage.This is a client-specific id that can be used to mark or identify messages between clients.
- Specified by:
correlationIdin interfaceMessage<E>- Parameters:
correlationId- The correlationId value to assign to thisMessageinstance.- Returns:
- this
Messageinstance.
-
contentType
public java.lang.String contentType()
- Specified by:
contentTypein interfaceMessage<E>- Returns:
- the assigned content type value for the message body section or null if not set.
-
contentType
public Message<E> contentType(java.lang.String contentType)
Description copied from interface:MessageSets the contentType value to assign to thisMessage.The RFC-2046 MIME type for the message's application-data section (body). As per RFC-2046 this can contain a charset parameter defining the character encoding used: e.g., 'text/plain; charset="utf-8"'.
For clarity, as per section 7.2.1 of RFC-2616, where the content type is unknown the content-type SHOULD NOT be set. This allows the recipient the opportunity to determine the actual type. Where the section is known to be truly opaque binary data, the content-type SHOULD be set to application/octet-stream.
When using an application-data section with a section code other than data, content-type SHOULD NOT be set.
- Specified by:
contentTypein interfaceMessage<E>- Parameters:
contentType- The contentType value to assign to thisMessageinstance.- Returns:
- this
Messageinstance.
-
contentEncoding
public java.lang.String contentEncoding()
- Specified by:
contentEncodingin interfaceMessage<E>- Returns:
- the assigned content encoding value for the message body section or null if not set.
-
contentEncoding
public Message<E> contentEncoding(java.lang.String contentEncoding)
Description copied from interface:MessageSets the contentEncoding value to assign to thisMessage.The content-encoding property is used as a modifier to the content-type. When present, its value indicates what additional content encodings have been applied to the application-data, and thus what decoding mechanisms need to be applied in order to obtain the media-type referenced by the content-type header field.
Content-encoding is primarily used to allow a document to be compressed without losing the identity of its underlying content type.
Content-encodings are to be interpreted as per section 3.5 of RFC 2616 [RFC2616]. Valid content-encodings are registered at IANA [IANAHTTPPARAMS].
The content-encoding MUST NOT be set when the application-data section is other than data. The binary representation of all other application-data section types is defined completely in terms of the AMQP type system.
Implementations MUST NOT use the identity encoding. Instead, implementations SHOULD NOT set this property. Implementations SHOULD NOT use the compress encoding, except as to remain compatible with messages originally sent with other protocols, e.g. HTTP or SMTP.
Implementations SHOULD NOT specify multiple content-encoding values except as to be compatible with messages originally sent with other protocols, e.g. HTTP or SMTP.
- Specified by:
contentEncodingin interfaceMessage<E>- Parameters:
contentEncoding- The contentEncoding value to assign to thisMessageinstance.- Returns:
- this
Messageinstance.
-
absoluteExpiryTime
public long absoluteExpiryTime()
- Specified by:
absoluteExpiryTimein interfaceMessage<E>- Returns:
- the configured absolute time of expiration for this message.
-
absoluteExpiryTime
public Message<E> absoluteExpiryTime(long expiryTime)
Description copied from interface:MessageSets the absolute expiration time value to assign to thisMessage.An absolute time when this message is considered to be expired.
- Specified by:
absoluteExpiryTimein interfaceMessage<E>- Parameters:
expiryTime- The absolute expiration time value to assign to thisMessageinstance.- Returns:
- this
Messageinstance.
-
creationTime
public long creationTime()
- Specified by:
creationTimein interfaceMessage<E>- Returns:
- the absolute time of creation for this message.
-
creationTime
public Message<E> creationTime(long createTime)
Description copied from interface:MessageSets the creation time value to assign to thisMessage.An absolute time when this message was created.
- Specified by:
creationTimein interfaceMessage<E>- Parameters:
createTime- The creation time value to assign to thisMessageinstance.- Returns:
- this
Messageinstance.
-
groupId
public java.lang.String groupId()
-
groupId
public Message<E> groupId(java.lang.String groupId)
Description copied from interface:MessageSets the groupId value to assign to thisMessage.Identifies the group the message belongs to.
-
groupSequence
public int groupSequence()
- Specified by:
groupSequencein interfaceMessage<E>- Returns:
- the assigned group sequence for this message.
-
groupSequence
public Message<E> groupSequence(int groupSequence)
Description copied from interface:MessageSets the group sequence value to assign to thisMessage.The relative position of this message within its group.
- Specified by:
groupSequencein interfaceMessage<E>- Parameters:
groupSequence- The group sequence to assign to thisMessageinstance.- Returns:
- this
Messageinstance.
-
replyToGroupId
public java.lang.String replyToGroupId()
- Specified by:
replyToGroupIdin interfaceMessage<E>- Returns:
- the client-specific id used so that client can send replies to this message to a specific group.
-
replyToGroupId
public Message<E> replyToGroupId(java.lang.String replyToGroupId)
Description copied from interface:MessageSets the replyTo group Id value to assign to thisMessage.This is a client-specific id that is used so that client can send replies to this message to a specific group.
- Specified by:
replyToGroupIdin interfaceMessage<E>- Parameters:
replyToGroupId- The replyTo group Id to assign to thisMessageinstance.- Returns:
- this
Messageinstance.
-
annotation
public java.lang.Object annotation(java.lang.String key)
Description copied from interface:MessageReturns the requested message annotation value from thisMessageif it exists or returns null otherwise.- Specified by:
annotationin interfaceMessage<E>- Parameters:
key- The key of the message annotation to query for.- Returns:
- the corresponding message annotation value of null if none was carried in this
Message.
-
hasAnnotation
public boolean hasAnnotation(java.lang.String key)
Description copied from interface:MessageQuery theMessageto determine if it carries the given message annotation key.- Specified by:
hasAnnotationin interfaceMessage<E>- Parameters:
key- The key of the message annotation to query for.- Returns:
trueif the Message carries the given message annotation.
-
hasAnnotations
public boolean hasAnnotations()
Description copied from interface:MessageQuery theMessageto determine if it carries any message annotations.- Specified by:
hasAnnotationsin interfaceMessage<E>- Returns:
trueif the Message carries any message annotations.
-
removeAnnotation
public java.lang.Object removeAnnotation(java.lang.String key)
Description copied from interface:MessageRemoves the given message annotation from the values carried in the message currently, if none was present than this method returnsnull.- Specified by:
removeAnnotationin interfaceMessage<E>- Parameters:
key- The key of the message annotation to query for removal.- Returns:
- the message annotation value that was previously assigned to that key.
-
forEachAnnotation
public Message<E> forEachAnnotation(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)
Description copied from interface:MessageInvokes the givenBiConsumeron each message annotation entry carried in thisMessage.- Specified by:
forEachAnnotationin interfaceMessage<E>- Parameters:
action- The action that will be invoked on each message annotation entry.- Returns:
- this
Messageinstance.
-
annotation
public ClientMessage<E> annotation(java.lang.String key, java.lang.Object value)
Description copied from interface:MessageSets the given message annotation value at the given key, replacing any previous value that was assigned to thisMessage.- Specified by:
annotationin interfaceMessage<E>- Parameters:
key- The message annotation key where the value is to be assigned.value- The value to assign to the given message annotation key.- Returns:
- this
Messageinstance.
-
property
public java.lang.Object property(java.lang.String key)
Description copied from interface:MessageReturns the requested application property value from thisMessageif it exists or returns null otherwise.
-
hasProperty
public boolean hasProperty(java.lang.String key)
Description copied from interface:MessageQuery theMessageto determine if it carries the given application property key.- Specified by:
hasPropertyin interfaceMessage<E>- Parameters:
key- The key of the application property to query for.- Returns:
trueif the Message carries the given application property.
-
hasProperties
public boolean hasProperties()
Description copied from interface:MessageQuery theMessageto determine if it carries any application properties.- Specified by:
hasPropertiesin interfaceMessage<E>- Returns:
trueif the Message carries any application properties.
-
removeProperty
public java.lang.Object removeProperty(java.lang.String key)
Description copied from interface:MessageRemoves the given application property from the values carried in the message currently, if none was present than this method returnsnull.- Specified by:
removePropertyin interfaceMessage<E>- Parameters:
key- The key of the application property to query for removal.- Returns:
- the application property value that was previously assigned to that key.
-
forEachProperty
public Message<E> forEachProperty(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)
Description copied from interface:MessageInvokes the givenBiConsumeron each application property entry carried in thisMessage.- Specified by:
forEachPropertyin interfaceMessage<E>- Parameters:
action- The action that will be invoked on each application property entry.- Returns:
- this
Messageinstance.
-
property
public ClientMessage<E> property(java.lang.String key, java.lang.Object value)
Description copied from interface:MessageSets the given application property value at the given key, replacing any previous value that was assigned to thisMessage.
-
footer
public java.lang.Object footer(java.lang.String key)
Description copied from interface:MessageReturns the requested footer value from thisMessageif it exists or returnsnullotherwise.
-
hasFooter
public boolean hasFooter(java.lang.String key)
Description copied from interface:MessageQuery theMessageto determine if it carries the given footer key.
-
hasFooters
public boolean hasFooters()
Description copied from interface:MessageQuery theMessageto determine if it carries any footers.- Specified by:
hasFootersin interfaceMessage<E>- Returns:
trueif the Message carries any footers.
-
removeFooter
public java.lang.Object removeFooter(java.lang.String key)
Description copied from interface:MessageRemoves the given footer from the values carried in the message currently, if none was present than this method returnsnull.- Specified by:
removeFooterin interfaceMessage<E>- Parameters:
key- The key of the footer to query for removal.- Returns:
- the footer value that was previously assigned to that key.
-
forEachFooter
public Message<E> forEachFooter(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)
Description copied from interface:MessageInvokes the givenBiConsumeron each footer entry carried in thisMessage.- Specified by:
forEachFooterin interfaceMessage<E>- Parameters:
action- The action that will be invoked on each footer entry.- Returns:
- this
Messageinstance.
-
footer
public ClientMessage<E> footer(java.lang.String key, java.lang.Object value)
Description copied from interface:MessageSets the given footer value at the given key, replacing any previous value that was assigned to thisMessage.
-
body
public E body()
Description copied from interface:MessageReturns the body value that is conveyed in this message or null if no body was set locally or sent from the remote if this is an incoming message.
-
body
public ClientMessage<E> body(E value)
Description copied from interface:Message
-
header
public Header header()
Description copied from interface:AdvancedMessageReturn the currentHeaderassigned to this message, if none was assigned yet then this method returnsnull.- Specified by:
headerin interfaceAdvancedMessage<E>- Returns:
- the currently assigned
Headerfor this message.
-
header
public ClientMessage<E> header(Header header)
Description copied from interface:AdvancedMessageAssign or replace theHeaderinstance associated with this message.- Specified by:
headerin interfaceAdvancedMessage<E>- Parameters:
header- TheHeadervalue to assign to this message.- Returns:
- this
AdvancedMessageinstance.
-
annotations
public MessageAnnotations annotations()
Description copied from interface:AdvancedMessageReturn the currentMessageAnnotationsassigned to this message, if none was assigned yet then this method returnsnull.- Specified by:
annotationsin interfaceAdvancedMessage<E>- Returns:
- the currently assigned
MessageAnnotationsfor this message.
-
annotations
public ClientMessage<E> annotations(MessageAnnotations messageAnnotations)
Description copied from interface:AdvancedMessageAssign or replace theMessageAnnotationsinstance associated with this message.- Specified by:
annotationsin interfaceAdvancedMessage<E>- Parameters:
messageAnnotations- TheMessageAnnotationsvalue to assign to this message.- Returns:
- this
AdvancedMessageinstance.
-
properties
public Properties properties()
Description copied from interface:AdvancedMessageReturn the currentPropertiesassigned to this message, if none was assigned yet then this method returnsnull.- Specified by:
propertiesin interfaceAdvancedMessage<E>- Returns:
- the currently assigned
Propertiesfor this message.
-
properties
public ClientMessage<E> properties(Properties properties)
Description copied from interface:AdvancedMessageAssign or replace thePropertiesinstance associated with this message.- Specified by:
propertiesin interfaceAdvancedMessage<E>- Parameters:
properties- ThePropertiesvalue to assign to this message.- Returns:
- this
AdvancedMessageinstance.
-
applicationProperties
public ApplicationProperties applicationProperties()
Description copied from interface:AdvancedMessageReturn the currentApplicationPropertiesassigned to this message, if none was assigned yet then this method returnsnull.- Specified by:
applicationPropertiesin interfaceAdvancedMessage<E>- Returns:
- the currently assigned
ApplicationPropertiesfor this message.
-
applicationProperties
public ClientMessage<E> applicationProperties(ApplicationProperties applicationProperties)
Description copied from interface:AdvancedMessageAssign or replace theApplicationPropertiesinstance associated with this message.- Specified by:
applicationPropertiesin interfaceAdvancedMessage<E>- Parameters:
applicationProperties- TheApplicationPropertiesvalue to assign to this message.- Returns:
- this
AdvancedMessageinstance.
-
footer
public Footer footer()
Description copied from interface:AdvancedMessageReturn the currentFooterassigned to this message, if none was assigned yet then this method returnsnull.- Specified by:
footerin interfaceAdvancedMessage<E>- Returns:
- the currently assigned
Footerfor this message.
-
footer
public ClientMessage<E> footer(Footer footer)
Description copied from interface:AdvancedMessageAssign or replace theFooterinstance associated with this message.- Specified by:
footerin interfaceAdvancedMessage<E>- Parameters:
footer- TheFootervalue to assign to this message.- Returns:
- this
AdvancedMessageinstance.
-
messageFormat
public int messageFormat()
- Specified by:
messageFormatin interfaceAdvancedMessage<E>- Returns:
- the currently assigned message format for this message.
-
messageFormat
public ClientMessage<E> messageFormat(int messageFormat)
Description copied from interface:AdvancedMessageSets the message format to use when the message is sent. The exact structure of a message, together with its encoding, is defined by the message format (default is the AMQP defined message format zero.This field MUST be specified for the first transfer of a multi-transfer message, if it is not set at the time of send of the first transfer the sender uses the AMQP default value of zero for this field.
The upper three octets of a message format code identify a particular message format. The lowest octet indicates the version of said message format. Any given version of a format is forwards compatible with all higher versions.
3 octets 1 octet +----------------+---------+ | message format | version | +----------------+---------+ | | msb lsb- Specified by:
messageFormatin interfaceAdvancedMessage<E>- Parameters:
messageFormat- The message format to encode into the transfer frame that carries the message.- Returns:
- this
AdvancedMessageinstance.
-
encode
public ProtonBuffer encode(java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations) throws ClientException
Description copied from interface:AdvancedMessageEncodes theAdvancedMessagefor transmission by the client. The providedDeliveryAnnotationscan be included or augmented by theAdvancedMessageimplementation based on the target message format. The implementation is responsible for ensuring that the delivery annotations are treated correctly encoded into the correct location in the message.- Specified by:
encodein interfaceAdvancedMessage<E>- Parameters:
deliveryAnnotations- AMapof delivery annotation values that were requested to be included in the transmitted message.- Returns:
- the encoded form of this message in a
ProtonBufferinstance. - Throws:
ClientException- if an error occurs while encoding the message data.
-
addBodySection
public ClientMessage<E> addBodySection(Section<?> bodySection)
Description copied from interface:AdvancedMessageAdds the givenSectionto the internal collection of sections that will be sent to the remote peer when this message is encoded. If a previous section was added by a call to theMessage.body(Object)method it should be retained as the first element of the running list of body sections contained in this message.The implementation should make an attempt to validate that sections added are valid for the message format that is assigned when they are added.
- Specified by:
addBodySectionin interfaceAdvancedMessage<E>- Parameters:
bodySection- TheSectioninstance to append to the internal collection.- Returns:
- this
AdvancedMessageinstance.
-
bodySections
public ClientMessage<E> bodySections(java.util.Collection<Section<?>> sections)
Description copied from interface:AdvancedMessageSets the bodySectioninstances to use when encoding this message. The value given replaces any existing sections assigned to this message through theMessage.body(Object)orAdvancedMessage.addBodySection(Section)methods. Calling this method with a null or empty collection is equivalent to calling theAdvancedMessage.clearBodySections()method.- Specified by:
bodySectionsin interfaceAdvancedMessage<E>- Parameters:
sections- TheCollectionofSectioninstance to assign this message.- Returns:
- this
AdvancedMessageinstance.
-
bodySections
public java.util.Collection<Section<?>> bodySections()
Description copied from interface:AdvancedMessageCreate and return an unmodifiableCollectionthat contains theSectioninstances currently assigned to this message. Changes to this message body after calling this will not be reflected in the returned collection.- Specified by:
bodySectionsin interfaceAdvancedMessage<E>- Returns:
- an unmodifiable
Collectionthat is a view of the current sections assigned to this message.
-
forEachBodySection
public ClientMessage<E> forEachBodySection(java.util.function.Consumer<Section<?>> consumer)
Description copied from interface:AdvancedMessagePerforms the given action for each bodySectionof theAdvancedMessageuntil all sections have been presented to the givenConsumeror the consumer throws an exception.- Specified by:
forEachBodySectionin interfaceAdvancedMessage<E>- Parameters:
consumer- theConsumerthat will operate on each of the body sections in this message.- Returns:
- this
AdvancedMessageinstance.
-
clearBodySections
public ClientMessage<E> clearBodySections()
Description copied from interface:AdvancedMessageClears all current bodySectionelements from theAdvancedMessage.- Specified by:
clearBodySectionsin interfaceAdvancedMessage<E>- Returns:
- this
AdvancedMessageinstance.
-
-