Start Bull Queue Process on Startup of Application

545 views Asked by At

I am creating queue and adding job inside my API.

I am also starting processing my job on API call.

const newQueue = createQueue(queueName, opts);

newQueue.add('JokesJob', data, options);

newQueue.process('JokesJob', async (job) => {
            data.jobId = job.id;
            await work(queueName, job.id, 'http://localhost:4045');
            job.progress(5);
        });

But when I restart my app. The queue should start processing on the job schedule.

But it does not start processing automatically.

What can I do? Is there any way?

Thanks

1

There are 1 answers

0
Samir Sayyad On

When you restart app, your current job have lock flag if not done, so it will stalled. You can listen for failed job and retry it.