I need to run a job in queue, which takes a long time (2 hours around). It checks availability of some certain service. So instead of running one job for two hours, which constantly (every fice mins) makes an API request, I thought to use scheduling of laravel for queued jobs. I could call scheduler from anywhere by Artisan helper:
Artisan::call('schedule:run', [
'args' => $args
]);
Which would dispatch a job. But can't figure out, how I can pass arguments ($arg1, $arg2, ..) in kernel.php, which my job file requires.
// Dispatch the job to the "heartbeats" queue...
$schedule->job(new Heartbeat($arg1, $arg2, ..), 'heartbeats')->everyFiveMinutes();
I tried to pass args in schedule method, but I suppose that's not the right way to do it.