Skip to main content

dispatch

Function dispatch 

Source
pub fn dispatch<J>(job: J) -> PendingDispatch<J>
where J: Job,
Expand description

Dispatch a job to its queue.

Await the returned PendingDispatch to push the job. Before you await it, you may choose the job’s connection, queue, and delay. The dispatch method that #[job] adds to each job calls this function.

Awaiting returns the job’s JobId. Inside a database transaction, the job waits for the transaction to commit, and Laravel discards the job if the transaction rolls back.

§Errors

Awaiting fails when the connection isn’t defined, the job can’t be encoded, or the connection can’t accept the job. A job on the sync connection runs as soon as it’s pushed, so awaiting also returns the job’s own error.

§Panics

Awaiting panics outside a request, a command, or an Application::scope.