1
0
mirror of https://github.com/taigrr/nats.docs synced 2025-01-18 04:03:23 -08:00

Update seq_num.md

This commit is contained in:
Ginger Collison 2019-10-04 11:12:18 -05:00 committed by GitHub
parent 81e5aa9ff7
commit 6ea23abb91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,20 +3,7 @@
A common problem for one-to-many messages is that a message can get lost or dropped due to a network failure. A simple pattern for resolving this situation is to include a sequence id with the message. Receivers can check the sequence id to see if they have missed anything. A common problem for one-to-many messages is that a message can get lost or dropped due to a network failure. A simple pattern for resolving this situation is to include a sequence id with the message. Receivers can check the sequence id to see if they have missed anything.
Sequence numbers combined with heartbeats in the absence of new data form a powerful and resilient pattern to detect loss. Systems that store and persist messages can also solve this problem, but sometimes are overkill for the problem at hand and usually cause additional management and operational cost. Sequence numbers combined with heartbeats in the absence of new data form a powerful and resilient pattern to detect loss. Systems that store and persist messages can also solve this problem, but sometimes are overkill for the problem at hand and usually cause additional management and operational cost.
<div class="graphviz"><code data-viz="dot"> ![seq numbers](/assets/images/seqno.svg)
digraph nats_pub_sub {
rankdir=LR
publisher [shape=box, style="rounded", label="Publisher"];
subject [shape=circle, label="Subject"];
sub [shape=box, style="rounded", label="Subscriber"];
publisher -> subject [label="updates.1"];
publisher -> subject [label="updates.2"];
publisher -> subject [label="updates.3"];
subject -> sub [label="updates.*"];
}
</code></div>
In order to really leverage sequence ids there are a few things to keep in mind: In order to really leverage sequence ids there are a few things to keep in mind:
@ -24,4 +11,4 @@ In order to really leverage sequence ids there are a few things to keep in mind:
* If possible, receivers should be able to ask for missing messages by id * If possible, receivers should be able to ask for missing messages by id
With NATS you can embed sequence ids in the message or include them as a token in the subject. For example, a sender can send messages to `updates.1`, `updates.2`, etc... and the subscribers can listen to `updates.*` and parse the subject to determine the sequence id. With NATS you can embed sequence ids in the message or include them as a token in the subject. For example, a sender can send messages to `updates.1`, `updates.2`, etc... and the subscribers can listen to `updates.*` and parse the subject to determine the sequence id.
Placing a sequence token into the subject may be desireable if the payload is unknown or embedding additional data such as a sequence number in the payload is not possible. Placing a sequence token into the subject may be desireable if the payload is unknown or embedding additional data such as a sequence number in the payload is not possible.