I
I
Isaac Clark2020-11-01 13:52:46
MongoDB
Isaac Clark, 2020-11-01 13:52:46

How to create a mail queue using kue?

Good afternoon.
There are letters that the user sends.
When sending, each letter is placed in the database, where it is assigned the number of the letter and the time it was added to the database.
In sending letters, there is a limit per minute, that is, the user cannot send more than 100 letters per minute. If the number of letters is exceeded, then the next letter will be queued and sent in a minute, and so on.
Here is part of my code.

queue.create(`email`, {
    title: `HELLO KUE 1`,
    id: Math.floor(Math.random() * Math.floor(100)),
    to: '[email protected]',
  })
    .save((err) => {
      if (!err) console.log(`error`);
    }
  );

But I don't understand how to properly call queue.process
Call setInterval every minute? I thought kue had a mechanism for that?
Please tell me how this can be done using kue

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question