Having
$this->dispatch(new SaveVideo($video, $api));
And then followed by
if ($user = Auth::user()) {
$this->dispatch(new RegisterView($video['id'], $user));
}
In the same controller, how can I ensure that the second dispatch only happens after the first one has finished? Any ideas?
Check out the Queue::after
method this should do what you require.
The Job Completion Event documentation states
The Queue::after method allows you to register a callback to be executed when a queued job executes successfully. This callback is a great opportunity to perform additional logging, queue a subsequent job, or increment statistics for a dashboard.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.