Interface Message<T>

Type Parameters:
T - decoded payload type

public interface Message<T>
A message as a handler sees it: the decoded payload plus everything known about how it arrived.

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 Details

    • payload

      T payload()
      Returns:
      the decoded payload
    • envelope

      Envelope envelope()
      Returns:
      the AceMQ metadata that travelled with this message
    • headers

      Map<String,Object> headers()
      Returns:
      application headers; AceMQ-owned headers are reflected in envelope()
    • routingKey

      Optional<String> 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:
      true when the attempt counter is still 1
    • replyTo

      default Optional<String> replyTo()
      Where the sender asked for a reply.

      Present only for a request. A handler answering one does not need to read this -- Responder does 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

      default Optional<String> contentType()
      Returns:
      what the sender said the body was, when it said anything
    • redelivered

      default boolean redelivered()
      Whether the broker set the AMQP redelivered flag 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:
      true when the broker marked the delivery as redelivered
    • withPayload

      <R> Message<R> withPayload(R payload)
      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