-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
how to stop a delay job? #87
Comments
You can use stop condition inside a job execute method. For example: class SomeJob implements \yii\queue\Job
{
public function execute($queue)
{
if (/* stop condition */) {
return;
}
// ...
}
} Also you can add behavior to component. Example: class StopBehavior extends Behavior
{
public function events()
{
return [
Queue::EVENT_BEFORE_EXEC => function (ExecEvent $event) {
if (Yii::$app->cache->exists('stoped' . $event->id)) {
Yii::$app->cache->delete('stoped' . $event->id);
$event->handled = true; // A job will not be executed
}
}
];
}
public function stop($jobId)
{
Yii::$app->cache->set('stoped' . $jobId, true);
}
} |
@zhuravljov how about making this behavior part of the extension? sounds really useful. |
@zhuravljov thank you . But it's too complicated for me. how about add a function like this.
|
the behavior provides that functionality @yoage |
@TerraSkye yes,I know but my class is not extend from component .
|
hello,I got a delay jobID and I want to stop it later. how to stop it ?
this is my code
Thank you!
The text was updated successfully, but these errors were encountered: