-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
Comments
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. |
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. |
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? |
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. |
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. |
Also, the possibility to disable a job would be nice. By e.g. instance count set to 0. |
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
The text was updated successfully, but these errors were encountered: