From f679971b40365557ada05baebd6f975ccc83b8fd Mon Sep 17 00:00:00 2001 From: Ginger Collison Date: Thu, 6 Feb 2020 12:04:17 -0600 Subject: [PATCH] Update unsub_after.md --- developing-with-nats/receiving/unsub_after.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/developing-with-nats/receiving/unsub_after.md b/developing-with-nats/receiving/unsub_after.md index 30b4cb9..c5d7e58 100644 --- a/developing-with-nats/receiving/unsub_after.md +++ b/developing-with-nats/receiving/unsub_after.md @@ -2,9 +2,9 @@ NATS provides a special form of unsubscribe that is configured with a message count and takes effect when that many messages are sent to a subscriber. This mechanism is very useful if only a single message is expected. -The message count you provide is the total message count for a subscriber. So if you unsubscribe with a count of 1, the server will stop sending messages to that subscription after it has received one message. If the subscriber has already received one or more messages, the unsubscribe will be immediate. This action based on history can be confusing if you try to auto unsubscribe on a long running subscription, but is logical for a new one. +The message count you provide is the total message count for a subscriber. So if you unsubscribe with a count of 1, the server will stop sending messages to that subscription after it has received one message. If the subscriber has already received one or more messages, the unsubscribe will be immediate. This action based on history can be confusing if you try to auto-unsubscribe on a long running subscription, but is logical for a new one. -Auto unsubscribe is based on the total messages sent to a subscriber, not just the new ones. Most of the client libraries also track the max message count after an auto unsubscribe request. On reconnect, this enables clients to resend the unsubscribe with an updated total. +Auto-unsubscribe is based on the total messages sent to a subscriber, not just the new ones. Most of the client libraries also track the max message count after an auto-unsubscribe request. On reconnect, this enables clients to resend the unsubscribe with an updated total. The following example shows unsubscribe after a single message: @@ -63,7 +63,7 @@ nc.close(); let nc = NATS.connect({ url: "nats://demo.nats.io:4222" }); -// `max` specifies the number of messages that the server will forward. +// `max` specifies the number of messages that the server will forward // The server will auto-cancel. let opts = {max: 10}; let sub = nc.subscribe(NATS.createInbox(), opts, (msg) => { @@ -127,8 +127,8 @@ end {% tab title="TypeScript" %} ```typescript -// `max` specifies the number of messages that the server will forward. -// The server will auto-cancel. +// `max` specifies the number of messages that the server will forward +// The server will auto-cancel let opts = {max: 10}; let sub = await nc.subscribe(createInbox(), (err, msg) => { t.log(msg.data);