Enable JetStream on the NATS server by adding jetstream: {} to the server config and restarting, or use a JetStream-enabled NATS server
Create a stream with nats stream add, specifying subjects to capture, retention policy (limits, interest, or workqueue), and storage type (file or memory)
Create a pull consumer with nats consumer add --pull, setting deliver policy (all, new, by-start-sequence, or by-start-time) and ack policy
In your client, fetch messages with js.fetch(consumer, batchSize) and acknowledge each with msg.ack() or nak for retry
Create a push consumer for lower-latency delivery by specifying a deliver subject; messages are pushed to subscribers on that subject
Known gotchas
JetStream streams persist subjects; if you publish to a subject not captured by any stream, the message is not stored and cannot be replayed
Pull consumers require explicit fetch calls; the consumer does not receive messages until the client asks, which can cause delays if not polled frequently enough
Consumer ack_wait must be set appropriately; if a consumer does not ack within ack_wait, the message is redelivered, potentially causing duplicates
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp