gocraft / work

Process background jobs in Go
MIT License
2.42k stars 342 forks source link

Retry single dead job type #236

Open shahbaz275817 opened 9 months ago

shahbaz275817 commented 9 months ago

Problem Statement:

There are different queues created for different job types which are separated by job names, but if the application fails to process the jobs successfully the jobs from all the queues end up in a single queue that has all the dead jobs.. which is conceptually similar to dead letter queue of RabbitMQ. In the gocraft webui we have an option to retry all the dead jobs which reties all the dead jobs of all job types or we can manually select specific jobs that we want to retry... But the problem arises when we have to retry thousands of dead jobs of a single queue or a job type. Right now we don't have the capability to do so. This PR solves this problem by adding a route and logic to retry all the dead jobs of a specific queue

Solution:

Add a route in webui and logic to retry only a specific job type from all the dead jobs

How to use

We can call this below sample curl with your job type or queue name of which you want to retry all the dead jobs

POST /retry_dead_job_type/<job-type> HTTP/1.1
Host: localhost:5040

Sample: POST /retry_dead_job_type/OrderCreated HTTP/1.1 Host: localhost:5040