Class MessageProperties
java.lang.Object
org.springframework.amqp.core.MessageProperties
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
StreamMessageProperties
Message Properties for an AMQP message.
- Author:
- Mark Fisher, Mark Pollack, Gary Russell, Dmitry Chernyshov, Artem Bilan, Csaba Soti, Raylax Grey, Ngoc Nhan
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final MessageDeliveryModestatic final Integerstatic final StringThe custom header to represent a number of retries a message is republished.static final Stringstatic final Stringstatic final Stringstatic final longThe maximum value of x-delay header. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean@Nullable AmqpAcknowledgmentReturn theAmqpAcknowledgmentfor consumer if any.@Nullable StringgetAppId()@Nullable String@Nullable String@Nullable String@Nullable Stringlong@Nullable StringGet the correlation id.@Nullable LongGet the x-delay header long value.@Nullable MessageDeliveryModelong@Nullable StringGet the message expiration.<T> @Nullable TTyped getter for a header.@Nullable TypeThe inferred target argument type when using a method-level@RabbitListener.@Nullable IntegerReturn the server's most recent estimate of the number of messages remaining on the queue.@Nullable StringlongReturn the publishing sequence number if publisher confirms are enabled; set by the template.@Nullable LongWhen a delayed message exchange is used the x-delay header on a received message contains the delay.@Nullable MessageDeliveryMode@Nullable String@Nullable String@Nullable StringReturn the user id from an incoming message.@Nullable Boolean@Nullable String@Nullable AddresslongThe number of retries for this message over broker.@Nullable ObjectThe target bean when using@RabbitListener.@Nullable MethodThe target method when using a@RabbitListener.@Nullable Date@Nullable StringgetType()@Nullable StringReturn the x-death header.inthashCode()voidIncrement a retry count for this message when it is re-published back to the broker.protected final booleanprotected final booleanbooleanbooleanWhen true; the message having these properties is the last message from a batch.booleanGet an internal flag used to communicate that conversion used projection; always false at the application level.@Nullable BooleanvoidsetAmqpAcknowledgment(AmqpAcknowledgment amqpAcknowledgment) Set anAmqpAcknowledgmentfor manual acks in the target message processor.voidvoidsetClusterId(String clusterId) voidsetConsumerQueue(String consumerQueue) voidsetConsumerTag(String consumerTag) voidsetContentEncoding(@Nullable String contentEncoding) voidsetContentLength(long contentLength) voidsetContentType(String contentType) voidsetCorrelationId(@Nullable String correlationId) Set the correlation id.voidsetDelayLong(@Nullable Long delay) Set the x-delay header to a long value.voidsetDeliveryMode(@Nullable MessageDeliveryMode deliveryMode) voidsetDeliveryTag(long deliveryTag) voidsetExpiration(String expiration) Set the message expiration.voidsetFinalRetryForMessageWithNoId(boolean finalRetryForMessageWithNoId) voidvoidsetHeaders(Map<String, Object> headers) Set headers.voidsetInferredArgumentType(Type inferredArgumentType) Set the inferred target argument type when using a method-level@RabbitListener.voidsetLastInBatch(boolean lastInBatch) Set to true to indicate these properties are for the last message in a batch.voidsetMessageCount(Integer messageCount) Set the message count.voidsetMessageId(String messageId) voidsetPriority(Integer priority) voidsetProjectionUsed(boolean projectionUsed) Set an internal flag used to communicate that conversion used projection; always false at the application level.voidsetPublishSequenceNumber(long publishSequenceNumber) Set the publishing sequence number, if publisher confirms are enabled; set by the template.voidsetReceivedDelayLong(Long receivedDelay) When a delayed message exchange is used the x-delay header on a received message contains the delay.voidsetReceivedDeliveryMode(MessageDeliveryMode receivedDeliveryMode) voidsetReceivedExchange(String receivedExchange) voidsetReceivedRoutingKey(String receivedRoutingKey) voidsetReceivedUserId(String receivedUserId) voidsetRedelivered(Boolean redelivered) voidsetReplyTo(@Nullable String replyTo) voidsetReplyToAddress(@Nullable Address replyTo) voidsetRetryCount(long retryCount) Set a number of retries for this message over broker.voidsetTargetBean(@Nullable Object targetBean) Set the target bean when using@RabbitListener.voidsetTargetMethod(@Nullable Method targetMethod) Set the target method when using a@RabbitListener.voidsetTimestamp(Date timestamp) voidvoidtoString()
-
Field Details
-
CONTENT_TYPE_BYTES
- See Also:
-
CONTENT_TYPE_TEXT_PLAIN
- See Also:
-
CONTENT_TYPE_SERIALIZED_OBJECT
- See Also:
-
CONTENT_TYPE_JSON
- See Also:
-
CONTENT_TYPE_JSON_ALT
- See Also:
-
CONTENT_TYPE_XML
- See Also:
-
SPRING_BATCH_FORMAT
- See Also:
-
BATCH_FORMAT_LENGTH_HEADER4
- See Also:
-
SPRING_AUTO_DECOMPRESS
- See Also:
-
X_DELAY
- See Also:
-
RETRY_COUNT
The custom header to represent a number of retries a message is republished. In case of server-side DLX, this header contains the value ofx-death.countproperty. When republish is done manually, this header has to be incremented by the application.- See Also:
-
DEFAULT_CONTENT_TYPE
- See Also:
-
DEFAULT_DELIVERY_MODE
-
DEFAULT_PRIORITY
-
X_DELAY_MAX
public static final long X_DELAY_MAXThe maximum value of x-delay header.- Since:
- 3.1.2
- See Also:
-
-
Constructor Details
-
MessageProperties
public MessageProperties()
-
-
Method Details
-
setHeader
-
setHeaders
-
getHeader
Typed getter for a header.- Type Parameters:
T- the type.- Parameters:
headerName- the header name.- Returns:
- the header value
- Since:
- 2.2
-
getHeaders
-
setTimestamp
-
getTimestamp
-
setMessageId
-
getMessageId
-
setUserId
-
getUserId
-
getReceivedUserId
Return the user id from an incoming message.- Returns:
- the user id.
- Since:
- 1.6
-
setReceivedUserId
-
setAppId
-
getAppId
-
setClusterId
-
getClusterId
-
setType
-
getType
-
setCorrelationId
Set the correlation id.- Parameters:
correlationId- the id.
-
getCorrelationId
-
setReplyTo
-
getReplyTo
-
setReplyToAddress
-
getReplyToAddress
-
setContentType
-
getContentType
-
setContentEncoding
-
getContentEncoding
-
setContentLength
public void setContentLength(long contentLength) -
getContentLength
public long getContentLength() -
isContentLengthSet
protected final boolean isContentLengthSet() -
setDeliveryMode
-
getDeliveryMode
-
getReceivedDeliveryMode
-
setReceivedDeliveryMode
-
setExpiration
Set the message expiration. This is a String property per the AMQP 0.9.1 spec. For RabbitMQ, this is a String representation of the message time to live in milliseconds.- Parameters:
expiration- the expiration.
-
getExpiration
Get the message expiration. This is a String property per the AMQP 0.9.1 spec. For RabbitMQ, this is a String representation of the message time to live in milliseconds.- Returns:
- the expiration.
-
setPriority
-
getPriority
-
setReceivedExchange
-
getReceivedExchange
-
setReceivedRoutingKey
-
getReceivedRoutingKey
-
getReceivedDelayLong
When a delayed message exchange is used the x-delay header on a received message contains the delay.- Returns:
- the received delay.
- Since:
- 3.1.2
- See Also:
-
setReceivedDelayLong
When a delayed message exchange is used the x-delay header on a received message contains the delay.- Parameters:
receivedDelay- the received delay.- Since:
- 3.1.2
- See Also:
-
setRedelivered
-
isRedelivered
-
getRedelivered
-
setDeliveryTag
public void setDeliveryTag(long deliveryTag) -
getDeliveryTag
public long getDeliveryTag() -
isDeliveryTagSet
protected final boolean isDeliveryTagSet() -
setMessageCount
Set the message count.- Parameters:
messageCount- the count- See Also:
-
getMessageCount
Return the server's most recent estimate of the number of messages remaining on the queue. Only applies to messages retrieved viabasicGet.- Returns:
- the count.
-
getConsumerTag
-
setConsumerTag
-
getConsumerQueue
-
setConsumerQueue
-
getDelayLong
Get the x-delay header long value.- Returns:
- the delay.
- Since:
- 3.1.2
-
setDelayLong
Set the x-delay header to a long value.- Parameters:
delay- the delay.- Since:
- 3.1.2
-
getRetryCount
public long getRetryCount()The number of retries for this message over broker.- Returns:
- the retry count
- Since:
- 3.2
-
setRetryCount
public void setRetryCount(long retryCount) Set a number of retries for this message over broker.- Parameters:
retryCount- the retry count.- Since:
- 3.2
- See Also:
-
incrementRetryCount
public void incrementRetryCount()Increment a retry count for this message when it is re-published back to the broker.- Since:
- 3.2
-
isFinalRetryForMessageWithNoId
public boolean isFinalRetryForMessageWithNoId() -
setFinalRetryForMessageWithNoId
public void setFinalRetryForMessageWithNoId(boolean finalRetryForMessageWithNoId) -
getPublishSequenceNumber
public long getPublishSequenceNumber()Return the publishing sequence number if publisher confirms are enabled; set by the template.- Returns:
- the sequence number.
- Since:
- 2.1
-
setPublishSequenceNumber
public void setPublishSequenceNumber(long publishSequenceNumber) Set the publishing sequence number, if publisher confirms are enabled; set by the template.- Parameters:
publishSequenceNumber- the sequence number.- Since:
- 2.1
-
getInferredArgumentType
The inferred target argument type when using a method-level@RabbitListener.- Returns:
- the type.
- Since:
- 1.6
-
setInferredArgumentType
Set the inferred target argument type when using a method-level@RabbitListener.- Parameters:
inferredArgumentType- the type.- Since:
- 1.6
-
getTargetMethod
The target method when using a@RabbitListener.- Returns:
- the method.
- Since:
- 1.6
-
setTargetMethod
Set the target method when using a@RabbitListener.- Parameters:
targetMethod- the target method.- Since:
- 1.6
-
getTargetBean
The target bean when using@RabbitListener.- Returns:
- the bean.
- Since:
- 1.6
-
setTargetBean
Set the target bean when using@RabbitListener.- Parameters:
targetBean- the bean.- Since:
- 1.6
-
isLastInBatch
public boolean isLastInBatch()When true; the message having these properties is the last message from a batch.- Returns:
- true for the last message.
- Since:
- 2.2
-
setLastInBatch
public void setLastInBatch(boolean lastInBatch) Set to true to indicate these properties are for the last message in a batch.- Parameters:
lastInBatch- true for the last.- Since:
- 2.2
-
isProjectionUsed
public boolean isProjectionUsed()Get an internal flag used to communicate that conversion used projection; always false at the application level.- Returns:
- true if projection was used.
- Since:
- 2.2.20
-
setProjectionUsed
public void setProjectionUsed(boolean projectionUsed) Set an internal flag used to communicate that conversion used projection; always false at the application level.- Parameters:
projectionUsed- true for projection.- Since:
- 2.2.20
-
getXDeathHeader
-
getAmqpAcknowledgment
Return theAmqpAcknowledgmentfor consumer if any.- Returns:
- the
AmqpAcknowledgmentfor consumer if any. - Since:
- 4.0
-
setAmqpAcknowledgment
Set anAmqpAcknowledgmentfor manual acks in the target message processor. This is only in-application a consumer side logic.- Parameters:
amqpAcknowledgment- theAmqpAcknowledgmentto use in the application.- Since:
- 4.0
-
hashCode
-
equals
-
toString
-