Run Queue Workers
Nest Queue provides a clean and maintaible API to manage message queues over several popular queue brokers like aws sqs, redis(coming soon), rabbitmq(coming soon).
note
You don't need to run QueueWorker if you are using sync
driver.
To perform action on any queue, you can make use of QueueWorker
class. To initialize,
Note that if any of the value is not passed, then default setting for the missing property will be used as fallback.
info
If you are using multiple queues/connections in your application, then you will have to run different queue worker instances for each queue/connection.
Functions
Run Listener
Now that we have created jobs and dispatched them, it is now necessary that we run the queue worker which will start pulling jobs from queues and process them.
Purge Queue
You may want to clear(purge) the queue, you can do so by calling clear
method.
Running
There are several ways through which you may want to run queue workers,
- via npm script
- [COMING SOON] custom cli commands (uses @squareboat/nest-console) internally.
via npm script
You can simply create your own typescript script like below
Now, do the following change in your package.json
Similarly for the purge function as well, you can create different commands.