embedded-queue icon indicating copy to clipboard operation
embedded-queue copied to clipboard

about delay queue

Open goldencolor opened this issue 3 years ago • 6 comments

**How to use the implementation delay queue?

For example, the queue task is executed every 10 seconds or a certain value**

goldencolor avatar Nov 18 '21 10:11 goldencolor

Currently, that feature is not available.

hajipy avatar Nov 19 '21 10:11 hajipy

Currently, that feature is not available.

How to perform some timed tasks when I am performing tasks?

After the execution, I paused using the timer to enable it and found that an error would be reported this._currentJob is not null

goldencolor avatar Nov 19 '21 10:11 goldencolor

Queue. shutdown is not method for pausing queue, it terminates queue. That queue will never be used again.

hajipy avatar Nov 19 '21 10:11 hajipy

Queue. shutdown is not method for pausing queue, it terminates queue. That queue will never be used again.

Then how should I suspend the queue

goldencolor avatar Nov 19 '21 10:11 goldencolor

My task is asynchronous, I want him to continue after performing a lot of actions

Now after using process, all actions will be executed quickly

this.queue.process( QueueEunm.SEND_MSG, async (job) => { // logger.service.info(job, QueueEunm.SEND_MSG +'Queue consumption...'); job.data; }, 1 );

goldencolor avatar Nov 19 '21 10:11 goldencolor

Then how should I suspend the queue

In the current implementation, the queue can only process the added jobs immediately. We have found that there is a demand for the new feature, but it cannot be implemented immediately.

In some cases, a close result may be achieved by waiting a certain amount of time at the end of the function passed to Queue.process.

quque.process(
    "message type",
    async (job) => {
        // your process here
        
        // wait 10 seconds.
        await new Promise((resolve) => { setTimeout(resolve, 10 * 1000); });
    },
    1
);

hajipy avatar Nov 19 '21 10:11 hajipy