Apache Kafka (TypeScript)
Use this skill for Kafka produce/consume/admin work driven from TypeScript/Node: prefer @platformatic/kafka, plus broker semantics, topic design, delivery guarantees, and ops that change app code.
Workflow
- Inspect the local surface:
- Package:
@platformatic/kafka(snapshot 2.8.0). Engines: Node>=22.22or>=24.6. Kafka brokers 3.5–4.2 (KRaft-only on Kafka 4.0+). - Clients:
Producer/Consumer/AdminwithbootstrapBrokers(not KafkaJSbrokers). - Topics: partitions, keys, RF /
min.insync.replicas, cleanup policy. - Semantics: at-least-once vs EOS; auto vs manual commit;
ProduceAcks.
- Package:
- For day-to-day how-to, follow usage-guide.md first.
- Refresh docs when versions drift. Start from source-map.md.
- Route deeper detail:
- Concepts (partitions, groups, retention, EOS): fundamentals.md.
@platformatic/kafkaAPI, serializers, streams, txns, SASL: platformatic-kafka.md.- Design, DLQ, outbox, monitoring: patterns-ops.md.
- Client landscape & brokers: clients-ecosystem.md.
- Prefer
@platformatic/kafkaoverkafkajs(unmaintained) and over nativenode-rdkafkaunless librdkafka is required. Do not invent KafkaJSconnect/subscribe/runAPIs on Platformatic. - Verify with focused produce/consume smokes, Admin topic create when needed, lag awareness, and
close()on shutdown.
Core Judgment
- Kafka is an append-only partitioned log. Ordering is per partition only; parallelism ceiling for a group = partition count.
- Default app semantic: at-least-once + idempotent handlers. Use transactions/
READ_COMMITTEDonly when you need Kafka↔Kafka EOS. - Durability triad: RF=3,
min.insync.replicas=2, producerProduceAcks.ALL(+ idempotent producer when available). - Keys: stable entity ids for order/partitioning. Compaction requires keys + tombstones (
nullvalue). - Prefer outbox/CDC over dual-write (DB + Kafka in one request).
- Poison pills: retry/DLQ then commit — never block a partition forever.
- Platformatic: long-lived clients; lazy connect;
close(); consume viaconsume()→ stream (for await/data/ concurrentforEach); offsets arebigint; headers on consume are aMap. - Pass
serializers/deserializers(e.g.stringSerializers) — default expectsBuffer. - Kafka 4.0+ is KRaft-only (no ZooKeeper). Local/dev: fix
advertised.listeners. - Prefer
bun/bunxin command examples; runtime must still satisfy Node engines for@platformatic/kafka.
Verification
Prefer repository-owned commands. For meaningful Kafka work, cover the relevant subset:
bun pm ls @platformatic/kafkaand Node ≥22.22 (or ≥24.6).- Smoke: Admin
createTopics(or existing topic),Producer.send,Consumer.consume+ process +close(). - Durability:
ProduceAcks.ALL; idempotence/transactionalIdwhen claiming EOS. - Consumer: correct
groupId, mode (EARLIEST/LATEST/COMMITTED), commit-after-process whenautocommit: false. - Security: TLS + SASL (or mTLS); no PLAINTEXT on public networks.
- Ops: consumer lag, under-replicated partitions, hot-key skew, rebalance storms (
max.poll/ processing time).
Report which checks ran, which did not, and broker/version assumptions that remain.