Retention Policy
describes based on what criteria a set will evict messages from its storage:LimitsPolicy
WorkQueuePolicy
InterestPolicy
MaxMsgs
for how many messages are kept in total, MaxBytes
for how big the set can be in total and MaxAge
for what is the oldest message that will be kept. These are the only limits in play with LimitsPolicy
retention.WorkQueuePolicy
the messages will be removed as soon as the Consumer received an Acknowledgement. In InterestPolicy
messages will be removed as soon as all Consumers of the stream for that subject have received an Acknowledgement for the message.WorkQueuePolicy
and InterestPolicy
the age, size and count limits will still apply as upper bounds.MaxMsgSize
.Discard Policy
sets how messages are discarded when limits set by LimitsPolicy
are reached. The DiscardOld
option removes old messages making space for new, while DiscardNew
refuses any new messages.WorkQueuePolicy
mode is a specialized mode where a message, once consumed and acknowledged, is removed from the Stream.Nats-Msg-Id
header.Nats-Msg-Id:1
header which tells JetStream to ensure we do not have duplicates of this message - we only consult the message ID not the body.--dupe-window
when creating a stream, though we would caution against large windows.Request()
to a subject covered by the configuration of the Stream the service will reply to you once it stored the message. If you just publish, it will not. A Stream can be set to disable Acknowledgements by setting NoAck
to true
in it's configuration.AckExplicit
AckAll
100
it will also acknowledge message 1
-99
, this is good for processing batches and to reduce ack overheadAckNone
ORDERS
Stream and DISPATCH
Consumer.Acknowledgement floor
is 1
and 1
, the sequence of the Consumer is 2
which means its had only the one message through and got acked. Since it was acked, nothing is pending or redelivering.Pending messages
.AckAck
+ACK
AckNak
-NAK
AckProgress
+WPI
AckWait
AckNext
+NXT
AckTerm
+TERM
AckAck
type of acknowledgement, by replying to the Ack with the body as indicated in Bytes
you can pick what mode of acknowledgement you want.AckNext
, support double acknowledgement - if you set a reply subject when acknowledging the server will in turn acknowledge having received your ACK.+NXT
acknowledgement can have a few formats: +NXT 10
requests 10 messages and +NXT {"no_wait": true}
which is the same data that can be sent in a Pull Request.AckSync()
(rather than Ack()
) function which sets a reply subject on the Ack and waits for a response from the server on the reception and processing of the acknowledgement. If the response received from the server indicates success you can be sure that the message will never be re-delivered by the consumer (due to a loss of your acknowledgement).DeliverPolicy
:all
last
tail -n 1 -f
new
by_start_time
OptStartTime
to be setby_start_sequence
OptStartSeq
to be setORDERS
and add 100 messages to it.DeliverAll
pull-based Consumer:DeliverLast
pull-based Consumer:MsgSetSeq
pull-based Consumer:MONITOR
a Consumer could very well be a short-lived thing there just while an operator is debugging the system, there is no need to remember the last seen position if all you are doing is wanting to observe the real-time state.--ephemeral
switch tells the system to make an Ephemeral Consumer.ReplayPolicy
and have values of ReplayInstant
and ReplayOriginal
.ReplayPolicy
on push-based Consumers.--sample 80
option to nats consumer add
, this tells the system to sample 80% of Acknowledgements.hello
message without headers will take 39 bytes.