Class Envelope.Builder

java.lang.Object
org.acemq.amqp.api.Envelope.Builder
Enclosing class:
Envelope

public static final class Envelope.Builder extends Object
Builds Envelope instances. Not thread safe; use one builder per envelope.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • id

      public Envelope.Builder id(@Nullable String id)
      Parameters:
      id - message identifier; a random UUID is generated when left unset
    • type

      public Envelope.Builder type(String type)
      Parameters:
      type - logical message type; required
    • version

      public Envelope.Builder version(int version)
      Parameters:
      version - payload schema version, at least 1; defaults to 1
    • correlationId

      public Envelope.Builder correlationId(@Nullable String correlationId)
      Parameters:
      correlationId - flow identifier; defaults to the message identifier
    • causationId

      public Envelope.Builder causationId(@Nullable String causationId)
      Parameters:
      causationId - identifier of the message that caused this one
    • attempt

      public Envelope.Builder attempt(int attempt)
      Parameters:
      attempt - delivery attempt, at least 1; defaults to 1
    • firstSeen

      public Envelope.Builder firstSeen(@Nullable Instant firstSeen)
      Parameters:
      firstSeen - first publish time; defaults to now
    • origin

      public Envelope.Builder origin(@Nullable String origin)
      Parameters:
      origin - publishing process, conventionally service@host
    • error

      public Envelope.Builder error(@Nullable String error)
      Parameters:
      error - why the message was dead-lettered or parked
    • claim

      public Envelope.Builder claim(@Nullable String claim)
      Parameters:
      claim - where the payload is, when the application stores it outside the message. Absent rather than empty: null and "" both mean no claim, and neither puts a header on the wire
    • replayedFrom

      public Envelope.Builder replayedFrom(@Nullable String replayedFrom)
      Parameters:
      replayedFrom - queue this message was replayed out of
    • replayedAt

      public Envelope.Builder replayedAt(@Nullable Instant replayedAt)
      Parameters:
      replayedAt - when it was replayed
    • replayCount

      public Envelope.Builder replayCount(int replayCount)
      Parameters:
      replayCount - how many times it has been replayed; must not be negative
    • route

      public Envelope.Builder route(@Nullable RoutingSlip route)
      Parameters:
      route - where the message is going, when it is travelling a pipeline
      Returns:
      this builder
    • header

      public Envelope.Builder header(String name, Object value)
      Adds one application header.
      Parameters:
      name - header name; must not use the AceMQ prefix
      value - header value
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the name is AceMQ-owned
    • headers

      public Envelope.Builder headers(@Nullable Map<String,Object> headers)
      Parameters:
      headers - application headers to add; AceMQ-owned names are ignored
    • build

      public Envelope build()
      Returns:
      the built envelope
      Throws:
      NullPointerException - if no type was set
      IllegalArgumentException - if the version or attempt is below 1