How to pause consuming for a while? #3594
-
Hi, I have a very simple use case, I want to pause a consumer for a while (almost 5 hrs) to do some maintenance and fixes and at the same time to prevent any message loss. I'm using Jetstream with pre-created durable consumers. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @AhmedAbouelkher, the mental model for a consumer is that its a service embedded in the NATS server that keeps track of messages that are consumed (by subscribers). To pause consumption, you can simply unsubscribe/stop the processes that are doing the actual message processing. Once you start them again, consumption will resume. |
Beta Was this translation helpful? Give feedback.
-
You can now pause a consumer with (JS) // jsm for jetstreamManager
await jsm.consumers.pause(
MyStreamName,
MyConsumerName,
new Date(Date.now() + 24 * 60 * 60) // optional
); here are whereabouts for each supported languages/sdk: nats-io/nats-architecture-and-design#266 |
Beta Was this translation helpful? Give feedback.
-
@tanguc is right - we added Consumer Pause, but you need to use preview/nightly server release, as it will be part of 2.11. |
Beta Was this translation helpful? Give feedback.
Hi @AhmedAbouelkher, the mental model for a consumer is that its a service embedded in the NATS server that keeps track of messages that are consumed (by subscribers). To pause consumption, you can simply unsubscribe/stop the processes that are doing the actual message processing. Once you start them again, consumption will resume.