Package com.aim2be.platform.outbox
Class OutboxRecord
java.lang.Object
com.aim2be.platform.outbox.OutboxRecord
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCompound primary key forOutboxRecord.static enumPer-row lifecycle. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum length of thelast_errorcolumn.static final intMaximum length of thetrace_parentcolumn.static final intMaximum length of thetrace_statecolumn. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIdentity is the compound PK(aggregateId, eventId); equals and hashCode purposefully exclude all mutable fields per JPA best practice (avoids identity flipping whenstatus/recordVersiontransitions inside a transaction).byte[]longintintgetTopic()inthashCode()voidsetAggregateId(UUID aggregateId) voidsetCreatedAt(Instant createdAt) voidsetEventId(UUID eventId) voidsetLastError(String lastError) Sets the last-error message, truncating toLAST_ERROR_MAX_LENGTHcharacters when longer (avoids DB constraint violations from unbounded Kafka exception stacks).voidsetPayloadBytes(byte[] payloadBytes) voidsetRecordVersion(long recordVersion) voidsetRetries(int retries) voidsetSchemaVersion(int schemaVersion) voidvoidsetStatus(OutboxRecord.Status status) voidvoidsetTraceParent(String traceParent) Sets the producing span's W3Ctraceparent, truncating toTRACE_PARENT_MAX_LENGTHcharacters when longer (defensive — a well-formedtraceparentis always within bounds).voidsetTraceState(String traceState) Sets the producing span's W3Ctracestate, truncating toTRACE_STATE_MAX_LENGTHcharacters when longer.toString()
-
Field Details
-
LAST_ERROR_MAX_LENGTH
public static final int LAST_ERROR_MAX_LENGTHMaximum length of thelast_errorcolumn. 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_LENGTHMaximum length of thetrace_parentcolumn. A W3Ctraceparentis 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_LENGTHMaximum length of thetrace_statecolumn. The W3Ctracestatelist is spec-bounded to 512 characters.- See Also:
-
-
Constructor Details
-
OutboxRecord
public OutboxRecord()
-
-
Method Details
-
getAggregateId
-
setAggregateId
-
getEventId
-
setEventId
-
getStatus
-
setStatus
-
getRetries
public int getRetries() -
setRetries
public void setRetries(int retries) -
getPayloadBytes
public byte[] getPayloadBytes() -
setPayloadBytes
public void setPayloadBytes(byte[] payloadBytes) -
getTopic
-
setTopic
-
getSchemaVersion
public int getSchemaVersion() -
setSchemaVersion
public void setSchemaVersion(int schemaVersion) -
getCreatedAt
-
setCreatedAt
-
getSentAt
-
setSentAt
-
getLastError
-
setLastError
Sets the last-error message, truncating toLAST_ERROR_MAX_LENGTHcharacters when longer (avoids DB constraint violations from unbounded Kafka exception stacks).- Parameters:
lastError- the raw error message; may benullto clear
-
getTraceParent
-
setTraceParent
Sets the producing span's W3Ctraceparent, truncating toTRACE_PARENT_MAX_LENGTHcharacters when longer (defensive — a well-formedtraceparentis always within bounds).- Parameters:
traceParent- the W3Ctraceparent; may benull
-
getTraceState
-
setTraceState
Sets the producing span's W3Ctracestate, truncating toTRACE_STATE_MAX_LENGTHcharacters when longer.- Parameters:
traceState- the W3Ctracestate; may benull
-
getRecordVersion
public long getRecordVersion() -
setRecordVersion
public void setRecordVersion(long recordVersion) -
equals
Identity is the compound PK(aggregateId, eventId); equals and hashCode purposefully exclude all mutable fields per JPA best practice (avoids identity flipping whenstatus/recordVersiontransitions inside a transaction). -
hashCode
public int hashCode() -
toString
-