public final class ServiceBusReceivedMessage extends Object implements MessageLockToken
Modifier and Type | Method and Description |
---|---|
byte[] |
getBody()
Gets the actual payload/data wrapped by the
ServiceBusReceivedMessage . |
String |
getContentType()
Gets the content type of the message.
|
String |
getCorrelationId()
Gets a correlation identifier.
|
String |
getDeadLetterDescription()
Gets the description for a message that has been dead-lettered.
|
String |
getDeadLetterReason()
Gets the reason for a message that has been dead-lettered.
|
String |
getDeadLetterSource()
Gets the name of the queue or subscription that this message was enqueued on, before it was
deadlettered.
|
long |
getDeliveryCount()
Gets the number of the times this message was delivered to clients.
|
Instant |
getEnqueuedTime()
Gets the instant at which this message was enqueued in Azure Service Bus.
|
Instant |
getExpiresAt()
Gets the instant at which this message will expire.
|
String |
getLabel()
Gets the label for the message.
|
Instant |
getLockedUntil()
Gets the instant at which the lock of this message expires.
|
String |
getLockToken()
Gets the lock token for the current message.
|
String |
getMessageId() |
String |
getPartitionKey()
Gets the partition key for sending a message to a partitioned entity.
|
Map<String,Object> |
getProperties()
Gets the set of free-form
ServiceBusReceivedMessage properties which may be used for passing metadata
associated with the ServiceBusReceivedMessage during Service Bus operations. |
String |
getReplyTo()
Gets the address of an entity to send replies to.
|
String |
getReplyToSessionId()
Gets or sets a session identifier augmenting the
ReplyTo address. |
Instant |
getScheduledEnqueueTime()
Gets the scheduled enqueue time of this message.
|
long |
getSequenceNumber()
Gets the unique number assigned to a message by Service Bus.
|
String |
getSessionId()
Gets the session id of the message.
|
Duration |
getTimeToLive()
Gets the duration before this message expires.
|
String |
getTo()
Gets the "to" address.
|
String |
getViaPartitionKey()
Gets the partition key for sending a message to a entity via another partitioned transfer entity.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromString
public byte[] getBody()
ServiceBusReceivedMessage
.
If the means for deserializing the raw data is not apparent to consumers, a common technique is to make use of
ServiceBusReceivedMessage.getProperties()
when creating the event, to associate serialization hints as an aid to consumers who
wish to deserialize the binary data.
public String getContentType()
ServiceBusReceivedMessage
.public String getCorrelationId()
Allows an application to specify a context for the message for the purposes of correlation, for example reflecting the MessageId of a message that is being replied to.
public String getDeadLetterDescription()
public String getDeadLetterReason()
public String getDeadLetterSource()
This value is only set in messages that have been dead-lettered and subsequently auto-forwarded from the dead-letter queue to another entity. Indicates the entity in which the message was dead-lettered. This property is read-only.
public long getDeliveryCount()
The count is incremented when a message lock expires, or the message is explicitly abandoned by the receiver. This property is read-only.
public Instant getEnqueuedTime()
The UTC instant at which the message has been accepted and stored in the entity. For scheduled messages, this reflects the time when the message was activated. This value can be used as an authoritative and neutral arrival time indicator when the receiver does not want to trust the sender's clock. This property is read-only.
public Instant getExpiresAt()
The value is the UTC instant for when the message is scheduled for removal and will no longer available for
retrieval from the entity due to expiration. Expiry is controlled by the TimeToLive
property. This property is computed from EnqueuedTime
plus TimeToLive
.
Instant
at which this message expirespublic String getLabel()
public String getLockToken()
The lock token is a reference to the lock that is being held by the broker in
ReceiveMode.PEEK_LOCK
mode.
Locks are used to explicitly settle messages as explained in the
product
documentation in more detail. The token can also be used to pin the lock permanently
through the Deferral API and, with that,
take the message out of the regular delivery state flow. This property is read-only.
getLockToken
in interface MessageLockToken
public Instant getLockedUntil()
For messages retrieved under a lock (peek-lock receive mode, not pre-settled) this property reflects the UTC
instant until which the message is held locked in the queue/subscription. When the lock expires, the DeliveryCount
is incremented and the message is again available for retrieval. This property
is read-only.
ReceiveMode.PEEK_LOCK
mode. Otherwise it returns null.public String getMessageId()
ServiceBusReceivedMessage
.public String getPartitionKey()
For partitioned
entities, setting this value enables assigning related messages to the same internal partition, so that
submission sequence order is correctly recorded. The partition is chosen by a hash function over this value and
cannot be chosen directly. For session-aware entities, the sessionId
property overrides
this value.
public Map<String,Object> getProperties()
ServiceBusReceivedMessage
properties which may be used for passing metadata
associated with the ServiceBusReceivedMessage
during Service Bus operations. A common use-case for
properties()
is to associate serialization hints for the ServiceBusReceivedMessage.getBody()
as an aid to consumers
who wish to deserialize the binary data.ServiceBusReceivedMessage
.public String getReplyTo()
This optional and application-defined value is a standard way to express a reply path to the receiver of the message. When a sender expects a reply, it sets the value to the absolute or relative path of the queue or topic it expects the reply to be sent to.
public String getReplyToSessionId()
ReplyTo
address.
This value augments the ReplyTo information and specifies which SessionId should be set for the reply when sent to the reply entity.
public Instant getScheduledEnqueueTime()
This value is used for delayed message availability. The message is safely added to the queue, but is not considered active and therefore not retrievable until the scheduled enqueue time. Mind that the message may not be activated (enqueued) at the exact given instant; the actual activation time depends on the queue's workload and its state.
public long getSequenceNumber()
The sequence number is a unique 64-bit integer assigned to a message as it is accepted and stored by the broker and functions as its true identifier. For partitioned entities, the topmost 16 bits reflect the partition identifier. Sequence numbers monotonically increase and are gapless. They roll over to 0 when the 48-64 bit range is exhausted. This property is read-only.
public String getSessionId()
ServiceBusReceivedMessage
.public Duration getTimeToLive()
This value is the relative duration after which the message expires, starting from the instant the message has
been accepted and stored by the broker, as captured in ServiceBusReceivedMessage.getScheduledEnqueueTime()
. When not set
explicitly, the assumed value is the DefaultTimeToLive set for the respective queue or topic. A message-level
TimeToLive value cannot be longer than the entity's DefaultTimeToLive setting and it is silently adjusted if it
does.
public String getTo()
public String getViaPartitionKey()
ServiceBusReceivedMessage.getPartitionKey()
and ensures that
messages are kept together and in order as they are transferred.Copyright © 2020 Microsoft Corporation. All rights reserved.