Only move job into Active when condition is met - Kue node js
- Dominant language
- JavaScript
- Stars
- 9.4k
- Forks
- 858
- PR merge metrics
- No merged PRs in 30d
Description
Is the following possible?
I was wondering if its possible to hold the job in a queued state before putting it into active only when it meets a condition. Example:
This is what the jobs look like =
```
var job = queue.create('myQueue', {
from: 'process1',
type: 'testMessage',
data: {
msg: 'Hello world!'
}
}).save(function(err) {
console.log('Job ' + job.id + ' saved to the queue.');
});
```
This is my queue.process =
```
queue.process('myQueue', 4, function(job, done) {
console.log('job', job.data)
handleMessage(job, done);
});
```
As soon as the job is picked up my queue.process, it is moved to active state. However, I only want to move the job into active state, when there is something in the database, like so:
```
myDatabase.find(function(err, docs) {
if(docs){
//move the job to active state
} else {
// hold the job in a queued state and query the dbs again in 10
// seconds
}
})
```
Is this possible? Any help would be appreciated as Im still trying to figure out if KUE would be appropriate for me
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the queue.process entry point and trace when a job changes from queued to active. Compare that lifecycle with the requested database condition and 10-second retry behavior; done would be a documented or agreed implementation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100