how to dispatch a job from terminala laravel code example
Example 1: laravel retry failed jobs command
php artisan queue:retry all
Example 2: laravel retry failed transactions
function tryFor10Seconds(Closure $closure) {
$runTheClosure = function ($closure) {
try {
DB::beginTransaction();
$closure();
DB::commit();
return true;
} catch (Exception $e) {
DB::rollBack();
return false;
}
};
$start = time();
do {
$result = $runTheClosure($closure);
} while(!$result && (time() - $start <= 10));
return $result;
}