Class ProcessedKafkaEvent
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.
@Immutableexcludes the entity from theEntityVersionParityArchUnit rule (ADR-0001 §1.4 + the siblingarchunit-rulesmodule) — dedup rows are append-only and the rule explicitly carves out@Immutableentities.
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.
-
Constructor Summary
ConstructorsConstructorDescriptionJPA-required no-arg constructor.ProcessedKafkaEvent(ProcessedKafkaEventId id, String topic, int partition, long offset) Convenience constructor for hand-built rows inDedupGuard.tryClaim(java.lang.String, java.lang.String, java.time.Instant, java.lang.String, int, long)/ unit tests. -
Method Summary
-
Constructor Details
-
ProcessedKafkaEvent
public ProcessedKafkaEvent()JPA-required no-arg constructor. -
ProcessedKafkaEvent
Convenience constructor for hand-built rows inDedupGuard.tryClaim(java.lang.String, java.lang.String, java.time.Instant, java.lang.String, int, long)/ unit tests.- Parameters:
id- composite key (consumer scope, event id, week start)topic- origin Kafka topic (forensic)partition- origin Kafka partition (forensic)offset- origin Kafka offset (forensic)
-
-
Method Details
-
getId
-
getFirstSeenAt
-
getTopic
-
getPartition
public int getPartition() -
getOffset
public long getOffset()
-