1 回答

TA貢獻1876條經驗 獲得超6個贊
您可以使用onConnection方法即時設置驅動程序。
$schedule->job((new Heartbeat)->onConnection('sync'))->everyFiveMinutes();
另一種選擇可能是在調用該job方法時,設置connection.
/**
* Add a new job callback event to the schedule.
*
* @param object|string $job
* @param string|null $queue
* @param string|null $connection
* @return \Illuminate\Console\Scheduling\CallbackEvent
*/
public function job($job, $queue = null, $connection = null)
{
return $this->call(function () use ($job, $queue, $connection) {
$job = is_string($job) ? Container::getInstance()->make($job) : $job;
if ($job instanceof ShouldQueue) {
$this->dispatchToQueue($job, $queue ?? $job->queue, $connection ?? $job->connection);
} else {
$this->dispatchNow($job);
}
})->name(is_string($job) ? $job : get_class($job));
}
- 1 回答
- 0 關注
- 139 瀏覽
添加回答
舉報