PENDINGAWAITING LINK
--:--:--▌

NATS JetStream, explained

JetStream is the persistence layer built into the NATS server. Core NATS delivers messages to whoever is listening right now; JetStream stores them so they can be replayed, acknowledged and delivered later.

CORE CONCEPTS
Streams
A stream captures every message published to its configured subjects (wildcards like orders.> allowed) and stores it in memory or on disk, with limits by age, size or count.
Consumers
A consumer is a view onto a stream that tracks what a client has read. Durable consumers remember their position across restarts; push consumers deliver to a subject, pull consumers fetch in batches.
Acknowledgements
Consumers can require each message to be acked. Unacked messages are redelivered, giving at-least-once delivery; with message de-duplication and double acks you can get exactly-once semantics.
Replication
In a clustered deployment a stream can keep up to 5 replicas, so data survives a server failure.
Key-Value & Object Store
Both are built on streams: a key-value bucket for configuration and state, an object store for larger files.
WHY MONITOR CONSUMER LAG

Lag is the number of stored messages a consumer hasn't processed yet. Rising lag means subscribers are falling behind publishers — the earliest sign of an overloaded or stuck service. Mission Control shows it live from the js.stream.lag subject.

Further reading: the official NATS JetStream documentation.