---
name: "apache-flink-stateful-stream-cep"
description: "Process millions of events per second with exactly-once state semantics and Complex Event Processing."
metadata:
  author: "Apache Software Foundation"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "configure flink rocksdb state"
  - "write flink watermark strategy"
  - "implement flink cep pattern"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Apache Flink Stateful Stream Processing & CEP

Builds stateful streaming pipelines in Apache Flink: configuring RocksDB state backends, savepoints/checkpoints, event-time watermarking, keyed state (ValueState, ListState), and Flink CEP pattern matching.

## When to Invoke
Invoke this skill whenever you need to:
- configure flink rocksdb state
- write flink watermark strategy
- implement flink cep pattern

## Execution SOP & Rules
1. Configure env.setStateBackend(new EmbeddedRocksDBStateBackend(true)) with incremental checkpoints.
2. Assign watermarks: WatermarkStrategy.forBoundedOutOfOrderness(Duration.ofSeconds(10)).withTimestampAssigner(...).
3. Define CEP pattern: Pattern.<Event>begin('start').where(...).next('middle').where(...).within(Time.minutes(5)).
4. Trigger manual savepoint: bin/flink savepoint <jobId> <savepointDirectory> prior to job upgrades.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
