RedisSMQ / Docs / Graceful Shutdown
RedisSMQ is designed to handle failures and unexpected shutdowns without losing messages. It ensures that all operations are transactional, guaranteeing data consistency and integrity.
To facilitate a smooth shutdown process and minimize the occurrence of failed messages, RedisSMQ provides a shutdown() method in supported classes. This method performs critical cleanup tasks, including:
- Completing in-progress message processing
- Saving any necessary state information
- Releasing system resources
- Gracefully closing Redis connections
consumer.shutdown((err) => {
if (err) {
console.log('An error occurred');
console.error(err);
} else {
console.log('Consumer has been shut down successfully');
}
});
Before terminating your application, be sure to call shutdown()
on the following classes:
- Consumer
- ConsumerGroups
- EventBus
- ExchangeDirect
- ExchangeFanOut
- ExchangeTopic
- Message
- Namespace
- Producer
- Queue
- QueueAcknowledgedMessages
- QueueDeadLetteredMessages
- QueueMessages
- QueuePendingMessages
- QueueRateLimit
- QueueScheduledMessages
For a comprehensive list of classes that support graceful shutdown functionality, please refer to the API Documentation.