Interface Message<T>
- Type Parameters:
T- decoded payload type
Implementations are immutable and safe to hand to another thread. Nothing here exposes the underlying broker object, because a handler that reaches for a channel is a handler that stops working when the transport changes.
-
Method Summary
Modifier and TypeMethodDescriptiondefault intattempt()Convenience accessor for the delivery attempt.envelope()headers()default booleanReports whether this is the first time the message has been delivered.payload()queue()default booleanWhether the broker set the AMQPredeliveredflag on this delivery.replyTo()Where the sender asked for a reply.<R> Message<R> withPayload(R payload) Returns a view of this message with a different payload, preserving all metadata.
-
Method Details
-
payload
T payload()- Returns:
- the decoded payload
-
envelope
Envelope envelope()- Returns:
- the AceMQ metadata that travelled with this message
-
headers
- Returns:
- application headers; AceMQ-owned headers are reflected in
envelope()
-
routingKey
- Returns:
- the routing key the message arrived with, when the broker supplies one
-
queue
String queue()- Returns:
- the queue this delivery came from
-
receivedAt
Instant receivedAt()- Returns:
- when this process received the delivery
-
attempt
default int attempt()Convenience accessor for the delivery attempt.- Returns:
- attempt number, starting at 1
-
isFirstAttempt
default boolean isFirstAttempt()Reports whether this is the first time the message has been delivered.Handlers that are expensive to run but cheap to check may use this to decide whether an idempotency lookup is worth doing.
- Returns:
truewhen the attempt counter is still 1
-
replyTo
Where the sender asked for a reply.Present only for a request. A handler answering one does not need to read this --
Responderdoes it -- but a consumer that wants to tell a request from a plain message can.- Returns:
- the reply queue, when the sender named one
-
contentType
- Returns:
- what the sender said the body was, when it said anything
-
redelivered
default boolean redelivered()Whether the broker set the AMQPredeliveredflag on this delivery.Set when the broker has handed this message out before and it came back unsettled, for example after a requeue or a closed channel. Unlike
attempt(), which counts the library's own retries, this is the broker's word on it.- Returns:
truewhen the broker marked the delivery as redelivered
-
withPayload
Returns a view of this message with a different payload, preserving all metadata.Used by decoding and upcasting, which change the payload while leaving the delivery untouched.
- Type Parameters:
R- replacement payload type- Parameters:
payload- replacement payload- Returns:
- a new message sharing this message's metadata
-