Implement streaming deduplication with keyed state and TTL in Flink or Kafka Streams

domain: nightlies.apache.org/flink · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Choose a deduplication key (e.g., event_id, idempotency_key) that uniquely identifies a logical event.
  2. In Flink SQL, use a ROW_NUMBER() window function partitioned by the dedup key and ordered by event_time, then filter WHERE row_num = 1 in a downstream view.
  3. In Flink DataStream API, use a KeyedProcessFunction keyed on the dedup key; store a flag in ValueState<Boolean> and set a timer to clear it after the dedup window expires (state TTL).
  4. Configure state TTL via StateTtlConfig.newBuilder(Time.hours(<n>)).setUpdateType(UpdateType.OnCreateAndWrite).build() to automatically purge state for keys not seen recently.
  5. In Kafka Streams, use a persistent KeyValueStore to track seen IDs and a punctuator or TTL tombstone to expire old entries.
  6. Test dedup effectiveness by replaying duplicate events and verifying exactly one output per logical event.

Known gotchas

Related routes

Implement Flink keyed state with TTL (Time-To-Live) to automatically expire state entries and bound memory usage in long-running jobs
flink.apache.org · 5 steps · unrated
Implement Flink keyed state with ValueState and ListState in a KeyedProcessFunction for stateful stream processing
nightlies.apache.org/flink · 6 steps · unrated
Implement Flink exactly-once end-to-end semantics with a Kafka source and a transactional Kafka sink using two-phase commit
nightlies.apache.org/flink · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans