Class OutboxRecord

java.lang.Object
com.aim2be.platform.outbox.OutboxRecord

@Entity public class OutboxRecord extends Object
Transactional outbox row, per ADR-0014 D-4.

Compound primary key (aggregate_id, event_id) mirrors the service-side primary-aggregate naming convention. status drives the poller's PENDING → SENT → ARCHIVED transitions; retries tracks transient broker failures; payload_bytes carries the Avro-serialised event body (length-prefixed wire format negotiated via com.aim2be.platform.schema.SchemaRegistryClient).

The @Version field enforces optimistic locking — see com.aim2be.platform.archunit.EntityVersionParity ArchRule (ADR-0001 §1.4).

v1.0 scaffold: getter/setter bodies are present (Lombok rejected for the v1.0 surface — explicit accessors make the entity contract auditable from the bytecode). Production behaviour ships in PR-PLATFORM-1.

  • Field Details

    • LAST_ERROR_MAX_LENGTH

      public static final int LAST_ERROR_MAX_LENGTH
      Maximum length of the last_error column. Producer-side relay and poller truncate longer error messages to this width before persisting (avoids unbounded growth from verbose Kafka exception stacks).
      See Also:
    • TRACE_PARENT_MAX_LENGTH

      public static final int TRACE_PARENT_MAX_LENGTH
      Maximum length of the trace_parent column. A W3C traceparent is a fixed 55 characters (00-<32-hex-trace>-<16-hex-span>-<2-hex-flags>); 64 leaves headroom for a future W3C version byte.
      See Also:
    • TRACE_STATE_MAX_LENGTH

      public static final int TRACE_STATE_MAX_LENGTH
      Maximum length of the trace_state column. The W3C tracestate list is spec-bounded to 512 characters.
      See Also:
  • Constructor Details

    • OutboxRecord

      public OutboxRecord()
  • Method Details

    • getAggregateId

      public UUID getAggregateId()
    • setAggregateId

      public void setAggregateId(UUID aggregateId)
    • getEventId

      public UUID getEventId()
    • setEventId

      public void setEventId(UUID eventId)
    • getStatus

      public OutboxRecord.Status getStatus()
    • setStatus

      public void setStatus(OutboxRecord.Status status)
    • getRetries

      public int getRetries()
    • setRetries

      public void setRetries(int retries)
    • getPayloadBytes

      public byte[] getPayloadBytes()
    • setPayloadBytes

      public void setPayloadBytes(byte[] payloadBytes)
    • getTopic

      public String getTopic()
    • setTopic

      public void setTopic(String topic)
    • getSchemaVersion

      public int getSchemaVersion()
    • setSchemaVersion

      public void setSchemaVersion(int schemaVersion)
    • getCreatedAt

      public Instant getCreatedAt()
    • setCreatedAt

      public void setCreatedAt(Instant createdAt)
    • getSentAt

      public Instant getSentAt()
    • setSentAt

      public void setSentAt(Instant sentAt)
    • getLastError

      public String getLastError()
    • setLastError

      public void setLastError(String lastError)
      Sets the last-error message, truncating to LAST_ERROR_MAX_LENGTH characters when longer (avoids DB constraint violations from unbounded Kafka exception stacks).
      Parameters:
      lastError - the raw error message; may be null to clear
    • getTraceParent

      public String getTraceParent()
    • setTraceParent

      public void setTraceParent(String traceParent)
      Sets the producing span's W3C traceparent, truncating to TRACE_PARENT_MAX_LENGTH characters when longer (defensive — a well-formed traceparent is always within bounds).
      Parameters:
      traceParent - the W3C traceparent; may be null
    • getTraceState

      public String getTraceState()
    • setTraceState

      public void setTraceState(String traceState)
      Sets the producing span's W3C tracestate, truncating to TRACE_STATE_MAX_LENGTH characters when longer.
      Parameters:
      traceState - the W3C tracestate; may be null
    • getRecordVersion

      public long getRecordVersion()
    • setRecordVersion

      public void setRecordVersion(long recordVersion)
    • equals

      public boolean equals(Object other)
      Identity is the compound PK (aggregateId, eventId); equals and hashCode purposefully exclude all mutable fields per JPA best practice (avoids identity flipping when status / recordVersion transitions inside a transaction).
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object