Example
Last updated
Last updated
Consider this architecture
While it is an incomplete architecture it does show a number of key points:
Many related subjects are stored in a Stream
Consumers can have different modes of operation and receive just subsets of the messages
Multiple Acknowledgement modes are supported
A new order arrives on ORDERS.received
, gets sent to the NEW
Consumer who, on success, will create a new message on ORDERS.processed
. The ORDERS.processed
message again enters the Stream where a DISPATCH
Consumer receives it and once processed it will create an ORDERS.completed
message which will again enter the Stream. These operations are all pull
based meaning they are work queues and can scale horizontally. All require acknowledged delivery ensuring no order is missed.
All messages are delivered to a MONITOR
Consumer without any acknowledgement and using Pub/Sub semantics - they are pushed to the monitor.
As messages are acknowledged to the NEW
and DISPATCH
Consumers, a percentage of them are Sampled and messages indicating redelivery counts, ack delays and more, are delivered to the monitoring system.
Additional documentation introduces the nats
utility and how you can use it to create, monitor, and manage streams and consumers, but for completeness and reference this is how you'd create the ORDERS scenario. We'll configure a 1 year retention for order related messages: