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

Cancel queue job and clear the queue. Also disable job #266

Open
paulreicherdt opened this issue Oct 26, 2021 · 6 comments
Open

Cancel queue job and clear the queue. Also disable job #266

paulreicherdt opened this issue Oct 26, 2021 · 6 comments
Labels

Comments

@paulreicherdt
Copy link

Hi,

thanks for this great set of libraries. Really helpful.

Is there a way to cancel all queue jobs and clear the queue? We have some long running jobs that need to be cancelled on event. And afterwards, the user can enqueue the job again.

And is there a way to disable/deactivate a job via settings? E.g. if we want to disable some job on specific environments.

Kind regards
Paul

@niemyjski
Copy link
Member

If you want to clear the queue you could call DeleteQueueAsync() but make sure you check the underlying implementation as it may completely delete the queue + configuration. We do this for our unit tests. Also you could always add a setting to your queue job and then look at that setting in dequeue to auto complete a queue entry.

@paulreicherdt
Copy link
Author

The question was - how to cancel an already running job (queue entry). So, usually, I would use CancellationTokenSource, create a CancellationToken, link it with others if necessary and then, I'm able to monitor this token and stop the job if cancellation were requested.

@niemyjski
Copy link
Member

I think what you are doing is the recommended way. @ejsmith, it might be nice to trigger the cancellation token we pass through to get cancelled from the passed in context?

@ejsmith
Copy link
Contributor

ejsmith commented Oct 26, 2021

Yeah, not sure exactly. When you call dequeue it takes a cancellationtoken that can be cancelled to stop the processing as long as you are checking in your long running code for it to be cancelled periodically.

@paulreicherdt
Copy link
Author

Yes, sure, I need to check the cancellation token periodically. I do it. And using cancellation token I'm able to cancel my job on any place. Or even within .net library code.
I have seen, that there is a cancellation token within job context. So, it may be a nice solution - to cancel all queued jobs by cancelling from the queue.

@paulreicherdt
Copy link
Author

Also, the possibility to disable a job would be nice. By e.g. instance count set to 0.

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

No branches or pull requests

3 participants