Originates inventory updates
Backend & Runtime / Knowledge library
NATS
subjects pub-sub request-reply and jetstream
Why learn NATS?
Useful for connecting services through lightweight message exchange. Delivery guarantees depend on the selected messaging mode and acknowledgment design.
Where it came from
NATS provides messaging primitives such as publish/subscribe and request/reply. JetStream adds persistence and streaming facilities distinct from core transient messaging.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Publish and subscribe on a test subject.
- Implement a bounded request-reply exchange.
- Contrast Core NATS with a JetStream stream.
- Test consumer acknowledgment and redelivery.
- Make a message handler idempotent under repeated delivery.
Documentation and sources
- Official project documentation (docs.nats.io)
Catalog research notes
- Research snapshot: September 9, 2026. This entry summarizes the linked primary documentation; it does not assert a latest release version.
Connect the ideas
Alternatives
Explore next
Real World Example
Global Logistics Inventory Synchronization
A global logistics provider managing real-time inventory across thousands of regional warehouses.
The business problem
Legacy polling mechanisms create high latency and database contention, causing inventory discrepancies when multiple regional hubs update stock levels simultaneously.
How this topic solves it
NATS provides a unified messaging backbone using Pub-Sub for real-time inventory broadcasts, Request-Reply for immediate stock verification, and JetStream for persistent, reliable event streaming of transaction logs.
- Deploy a NATS cluster to act as the central message broker for all regional warehouse nodes.
- Implement Pub-Sub topics for broadcasting inventory updates to all interested regional dashboards.
- Utilize Request-Reply patterns for synchronous stock checks between a warehouse and the central database.
- Configure JetStream streams to persist critical transaction events, ensuring data recovery if a regional node disconnects.
- Establish consumer groups within JetStream to process inventory reconciliation tasks in parallel.
This diagram shows how inventory updates flow from warehouses to the NATS cluster and back to consumers.
Broker for Pub-Sub and JetStream
Source of truth for stock
Processes persistent events
- Warehouse Node → Publishes update → NATS Cluster
- NATS Cluster → Request-Reply check → Central Database
- NATS Cluster → Streams event → Consumer Group
Expected business outcome
The system achieves eventual consistency across global nodes with reduced database load and improved responsiveness for stock verification requests.
Limitations and checks
JetStream persistence introduces storage overhead and potential latency during stream replication; monitor consumer lag metrics to ensure the system keeps pace with incoming transaction volume.