Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeOnComplete(true) does not delete job when it is done #77

Open
mmarshak opened this issue Jan 19, 2017 · 8 comments
Open

removeOnComplete(true) does not delete job when it is done #77

mmarshak opened this issue Jan 19, 2017 · 8 comments

Comments

@mmarshak
Copy link

I can not make the job auto removed when complete.

I define the job as -
job = Queue.createJob(type, payload)
.attempts(3)
.backoff( {delay: 10*1000, type:'fixed'} ) // // back of 10 seconds after each failure
.priority('normal')
.removeOnComplete(true);

And I use schedule to run it one time (not every) but it does not delete the job automatically. When I use just Kue instead it does. Any guidance ?

@mmarshak
Copy link
Author

Does somebody have it working?

@lykmapipo
Copy link
Owner

@mmarshak I have the same problem and I will work to fix it.

@mmarshak
Copy link
Author

Thanks

@lykmapipo
Copy link
Owner

@mmarshak May please add a fail test(spec) for this so that i can work around your specification.

Appreciated.

@mmarshak
Copy link
Author

Hi @lykmapipo,

As I wrote in my post if I create the job, I expect that cue-scheduler will delete the job when it complete, but it does not.

job = Queue.createJob(type, payload)
.attempts(3)
.backoff( {delay: 10*1000, type:'fixed'} ) // // back of 10 seconds after each failure
.priority('normal')
.removeOnComplete(true);

So in my implementation I comment out the - .removeOnComplete(true);
And in order to clean the complete job I am listening to Queue events for the event 'job complete', and then I delete the job, which works.

Bellow is the code I use for that -

// Queue events
Queue.on('job enqueue', function(id, type){

	//console.log( "Queue-Job job# " +id + " got queued of type " + type );
    logKue( "Queue-Job job# " +id + " got queued of type " + type );

}).on('job complete', function(id, result){

	//console.log("Queue-Job job# " + id + " completed with data " +  util.inspect(result));
    logKue("Queue-Job job# " + id + " completed with data " +  util.inspect(result));
	//logKue("Queue-Job job# " + id + " completed ");

	// Remove the job upon its completion
	kue.Job.get(id, function(err, job){
	    if (err) {
	    	return;
	    }

	    job.remove(function(err){
	      if (err) {
	      	logError("Failed to remove job %s after it was completed, got an error %s", job.id, util.inspect(err));		
	      }
	      else {
	      	log('removed completed job #%d', job.id);
	      	//console.log('removed completed job #%d', job.id);
	      }
	    });
	  });

It will be great if the .removeOnComplete(true); was doing it job as it does for the regular Kue.
I am sure it will make other people easier.

Thanks

@banduk
Copy link

banduk commented May 9, 2017

Same problem here.

Any updateon that?

lykmapipo added a commit that referenced this issue Oct 29, 2018
@rodrigooler
Copy link

Same problem here.

@lykmapipo
Copy link
Owner

@rodrigooler Please use latest version. I merged #124. Hope it will fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants