Class ProcessedKafkaEvent

java.lang.Object
com.aim2be.platform.dedup.ProcessedKafkaEvent

@Entity public class ProcessedKafkaEvent extends Object
Marker row stamped by a Kafka consumer when an event is first observed (per ADR-0014 D-4).

The composite key ProcessedKafkaEventId(consumer_scope_id, event_id, week_start) — IS the dedup contract: the row's existence is the "already processed" signal. INSERT-OR-NOTHING via Postgres ON CONFLICT DO NOTHING (see ProcessedKafkaEventRepository.insertOrNothing(java.lang.String, java.lang.String, java.time.LocalDate, java.time.Instant, java.lang.String, int, long)) is atomic at the database level and races safely across concurrent consumer pods.

Rows are immutable post-insert. No @Version is required:

  • There is no update path — the row is either present or absent.
  • @Immutable excludes the entity from the EntityVersionParity ArchUnit rule (ADR-0001 §1.4 + the sibling archunit-rules module) — dedup rows are append-only and the rule explicitly carves out @Immutable entities.

Forensic indexes on (topic, partition) support post-incident triage queries ("which partition of which topic surfaced this event?") without scanning the entire weekly partition.

Partitioning: the physical table is declared PARTITION BY RANGE (week_start) and managed by pg_partman with premake=4, 90-day retention, daily pg_cron maintenance (per ADR-0014 §L-7 + §L-8). The Flyway migration that CREATEs the table is OWNED BY THE CONSUMING SERVICE — this module only ships the entity + repository. See README.md for the canonical template.

See Also: