Class ErrorEventOutboxWriter
ErrorEvent to the ADR-0014 outbox in an
independent (Propagation.REQUIRES_NEW) transaction.
Why a separate transaction (ADR-0015 D-3). Most domain errors are
caught while a business transaction is failing/rolling back. If the
error-event outbox row shared that transaction it would roll back too —
losing the error exactly when it matters. REQUIRES_NEW commits the
error-event row independently, so it survives the business rollback; it also
opens its own transaction for errors raised outside any transaction (gRPC
interceptor, HTTP boundary, scheduled job, consumer error handler).
Why a separate bean (not a @Transactional method on
ErrorEventPublisher): Spring's transactional proxy is bypassed on
self-invocation, so the REQUIRES_NEW boundary must live on a distinct
injected bean to take effect (same lesson as the notification-service
self-invocation fix, Memora #3560/#326).
The payload is the RAW protobuf encoding (AbstractMessageLite.toByteArray())
— no Apicurio wire-format header (ADR-0015 D-2: the observability path must not
depend on the schema registry). Uses the byte[] OutboxPublisher.publish
overload because ErrorEvent has no outbox-event_id field to embed.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ErrorEventOutboxWriter
-
-
Method Details
-
write
@Transactional(propagation=REQUIRES_NEW) public UUID write(com.aim2be.observability.v1.ErrorEvent event) Persists the serialized event to the outbox in a new transaction and returns the outbox-issuedeventId.- Parameters:
event- the populated error event (not null)- Returns:
- the outbox row's
eventId(UUIDv7)
-