Class OutboundMessage

java.lang.Object
org.acemq.amqp.transport.OutboundMessage

public final class OutboundMessage extends Object
A message on its way to the broker, already encoded.

The transport does not know what the bytes mean, and does not add AceMQ headers: the core has already flattened the envelope into headers() before handing it over.

  • Method Details

    • body

      public static OutboundMessage.Builder body(byte[] body)
      Parameters:
      body - encoded payload
      Returns:
      a builder defaulting to a persistent, mandatory publish
    • exchange

      public String exchange()
      Returns:
      target exchange, or the empty string to publish directly to a queue
    • routingKey

      public String routingKey()
    • body

      public byte[] body()
      Returns:
      the encoded payload; the array is shared, so callers must not modify it
    • headers

      public Map<String,Object> headers()
    • messageId

      public @Nullable String messageId()
    • contentType

      public @Nullable String contentType()
    • persistent

      public boolean persistent()
      Returns:
      whether the broker should persist the message across a restart
    • mandatory

      public boolean mandatory()
      Returns:
      whether an unroutable message must be returned rather than dropped
      See Also:
    • expiration

      public Optional<Duration> expiration()
      How long the message stays worth delivering.

      Per-message, and enforced by the broker rather than by anything here. A transport that cannot express it must say so rather than dropping it: a message expected to expire in five minutes and instead kept forever is a slow leak, and one delivered long after it stopped meaning anything is worse than one never delivered.

      Returns:
      the time-to-live, when one was set
    • priority

      public Optional<Integer> priority()
      Returns:
      the priority this message was published with, if any
    • replyTo

      public Optional<String> replyTo()
      Returns:
      the queue a reply should be sent to, if this message expects one
    • alwaysConfirmed

      public boolean alwaysConfirmed()
      Whether this must be confirmed and checked for a return even on a connection made without publisher confirms.

      Set on everything the library publishes on a caller's behalf: a retry hop, a move to {queue}.dlq or {queue}.parked, a replay, a pipeline or routing-slip hop, a scheduled hop or delivery, an outbox record, a reply. Each acknowledges a message or marks a record done once the send returns, and an unconfirmed publish can only ever be reported as routed. A caller's own publishes keep the mode the connection was made with.

      Returns:
      whether the transport must confirm this publish whatever the connection's mode
    • toString

      public String toString()
      Overrides:
      toString in class Object