mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
Major rewrite of NATS Streaming Server concepts section
and updates to the developing section. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
9
nats_streaming/channels/subscriptions/durable.md
Normal file
9
nats_streaming/channels/subscriptions/durable.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Durable
|
||||
|
||||
If an application wishes to resume message consumption from where it previously stopped, it needs to create a durable subscription. It does so by providing a durable name, which is combined with the client ID provided when the client created its connection. The server then maintain the state for this subscription even after the client connection is closed.
|
||||
|
||||
***Note: The starting position given by the client when restarting a durable subscription is ignored.***
|
||||
|
||||
When the application wants to stop receiving messages on a durable subscription, it should close - but *not unsubscribe*- this subscription. If a given client library does not have the option to close a subscription, the application should close the connection instead.
|
||||
|
||||
When the application wants to delete the subscription, it must unsubscribe it. Once unsubscribed, the state is removed and it is then possible to re-use the durable name, but it will be considered a brand new durable subscription, with the start position being the one given by the client when creating the durable subscription.
|
||||
11
nats_streaming/channels/subscriptions/queue-group.md
Normal file
11
nats_streaming/channels/subscriptions/queue-group.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Queue Group
|
||||
|
||||
When consumers want to consume from the same channel but each receive a different message, as opposed to all receiving the same messages, they need to create a queue subscription. When a queue group name is specified, the server will send each messages from the log to a single consumer in the group. The distribution of these messages is not specified, therefore applications should not rely on an expected delivery scheme.
|
||||
|
||||
After the first queue member is created, any other member joining the group will receive messages based on where the server is in the message log for that particular group. That means that starting position given by joining members is ignored by the server.
|
||||
|
||||
When the last member of the group leaves (subscription unsubscribed/closed/or connection closed), the group is removed from the server. The next application creating a subscription with the same name will create a new group, starting at the start position given in the subscription request.
|
||||
|
||||
A queue subscription can also be durable. For that, the client needs to provide a queue and durable name. The behavior is, as you would expect, a combination of queue and durable subscription. Unlike a durable subscription, though, the client ID is not part of the queue group name. It makes sense, because since client ID must be unique, it would prevent more than one connection to participate in the queue group. The main difference between a queue subscription and a durable one, is that when the last member leaves the group, the state of the group will be maintained by the server. Later, when a member rejoins the group, the delivery will resume.
|
||||
|
||||
***Note: For a durable queue subscription, the last member to * unsubscribe * (not simply close) causes the group to be removed from the server.***
|
||||
11
nats_streaming/channels/subscriptions/redelivery.md
Normal file
11
nats_streaming/channels/subscriptions/redelivery.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Redelivery
|
||||
|
||||
When the server sends a message to a consumer, it expects to receive an ACK from this consumer. The consumer is the one specifying how long the server should wait before resending all unacknowledged messages to the consumer.
|
||||
|
||||
When the server restarts and recovers unacknowledged messages for a subscription, it will first attempt to redelivery those messages before sending new messages. However, if during the initial redelivery some messages don't make it to the client, the server cannot know that and will enable delivery of new messages.
|
||||
|
||||
***So it is possible for an application to receive redelivered messages mixed with new messages. This is typically what happens outside of the server restart scenario.***
|
||||
|
||||
For queue subscriptions, if a member has unacknowledged messages, when this member `AckWait` (which is the duration given to the server before the server should attempt to redeliver unacknowledged messages) time elapses, the messages are redelivered to any other member in the group (including itself).
|
||||
|
||||
If a queue member leaves the group, its unacknowledged messages are redistributed to other queue members.
|
||||
3
nats_streaming/channels/subscriptions/regular.md
Normal file
3
nats_streaming/channels/subscriptions/regular.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Regular
|
||||
|
||||
The state of these subscriptions is removed when they are unsubscribed or closed (which is equivalent for this type of subscription) or the client connection is closed (explicitly by the client, or closed by the server due to timeout). They do, however, survive a *server* failure (if running with a persistent store).
|
||||
13
nats_streaming/channels/subscriptions/subscriptions.md
Normal file
13
nats_streaming/channels/subscriptions/subscriptions.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Subscriptions
|
||||
|
||||
A client creates a subscription on a given channel. Remember, there is no support for wildcards, so a subscription is really tied to
|
||||
one and only one channel. The server will maintain the subscription state on behalf of the client until the later closes the subscription (or its connection).
|
||||
|
||||
If there are messages in the log for this channel, messages will be sent to the consumer when the subscription is created. The server will
|
||||
send up to the maximum number of inflight messages as given by the client when creating the subscription.
|
||||
|
||||
When receiving ACKs from the consumer, the server will then deliver more messages, if more are available.
|
||||
|
||||
A subscription can be created to start at any point in the message log, either by message sequence, or by time.
|
||||
|
||||
Following pages describe all types of subscription.
|
||||
Reference in New Issue
Block a user