Skip to content

Latest commit

 

History

History
51 lines (41 loc) · 1.91 KB

graceful-shutdown.md

File metadata and controls

51 lines (41 loc) · 1.91 KB

RedisSMQ / Docs / Graceful Shutdown

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:

  1. Completing in-progress message processing
  2. Saving any necessary state information
  3. Releasing system resources
  4. Gracefully closing Redis connections

Example of Shutting Down a Consumer:

consumer.shutdown((err) => {
  if (err) {
    console.log('An error occurred');
    console.error(err);
  } else {
    console.log('Consumer has been shut down successfully');
  }
});

Important Classes to Shut Down Before Exiting

Before terminating your application, be sure to call shutdown() on the following classes:

For a comprehensive list of classes that support graceful shutdown functionality, please refer to the API Documentation.