Skip to content

Does the NATS source drain messages when shutdown signal is given? #21756

Answered by jszwedko
benjamin-awd asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @benjamin-awd !

The expectation is that sources stop consuming when a SIGTERM is received. Any in-flight data continues to be processed until there is none or the graceful shutdown timeout is hit. For the nats source, this is handled by

let stream = subscriber.take_until(shutdown);
which stops consuming the subscriber channel when a shutdown is received.

It is possible that an additional unsubscribe() call should be in there, though, to tell NATs to stop forwarding messages, but we may be relying on the Drop behavior of the Subscriber which calls unsubscribe as you can see here: https://docs.rs/async-nats/0.37.0/src/async_…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@benjamin-awd
Comment options

Answer selected by benjamin-awd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants