class CallQueuedHandler

Constants

protected MISSING_MODEL_FAILURE_CONTEXT_KEY

The context key for the job being failed because its command's models are missing.

Properties

protected mixed $runningCommand

The command currently being processed.

Methods

__construct(Dispatcher $dispatcher, Container $container)

Create a new handler instance.

void
call(Job $job, array $data)

Handle the queued job.

mixed
getCommand(array $data)

Get the command from the given payload.

mixed
dispatchThroughMiddleware(Job $job, mixed $command)

Dispatch the given job / command through its specified middleware.

mixed
resolveHandler(Job $job, mixed $command)

Resolve the handler for the given command.

mixed
setJobInstanceIfNecessary(Job $job, mixed $instance)

Set the job instance of the given class if necessary.

void
ensureNextJobInChainIsDispatched(mixed $command)

Ensure the next job in the chain is dispatched if applicable.

void
ensureSuccessfulBatchJobIsRecorded(mixed $command)

Ensure the batch is notified of the successful job completion.

bool
uniqueJobLockShouldBeReleased(Job $job, mixed $command)

Determine if the unique job lock should be released.

string
getUniqueJobLockOwner(Job $job, mixed $command)

Resolve the unique lock owner carried by the command or its queued payload.

void
ensureUniqueJobLockIsReleased(mixed $command, bool $onlyOwned = false, Job|null $job = null)

Ensure the lock for a unique job is released.

bool
commandShouldBeDebounced(mixed $command)

Determine if the debounced command was superseded by a newer dispatch.

void
deleteDebouncedJob(Job $job, mixed $command)

Handle a debounced job by firing an event and deleting it.

bool
commandShouldBeUnique(mixed $command)

Determine if the given command should be unique.

bool
commandShouldBeUniqueUntilProcessing(mixed $command)

Determine if the given command should be unique until processing begins.

void
handleModelNotFound(Job $job, Throwable $e)

Handle a model not found exception.

void
ensureUniqueJobLockIsReleasedForMissingModel(Job|null $job, array $payload, bool $beforeProcessing)

Release the unique lock of a job whose command cannot be restored because its models are missing.

bool
ownerlessUniqueLockMayBeReleasedForMissingModel(Job|null $job, array $payload, bool $beforeProcessing)

Determine if an ownerless unique lock still belongs to a job whose models are missing.

void
ensureUniqueJobLockIsReleasedViaContext()

Ensure the lock for a unique job is released via context.

void
ensureSuccessfulBatchJobIsRecordedForMissingModel(Job $job, string $class)

Record a potentially batched job as successful when deleted because models were missing.

void
failed(array $data, Throwable|null $e, string $uuid, Job|null $job = null)

Call the failed method on the job instance.

void
ensureFailedBatchJobIsRecorded(string $uuid, mixed $command, Throwable|null $e)

Ensure the batch is notified of the failed job.

void
ensureFailedBatchJobIsRecordedForMissingModel(string $uuid, array $data, Throwable|null $e)

Record a potentially batched job as failed when its models are missing.

void
ensureChainCatchCallbacksAreInvoked(string $uuid, mixed $command, Throwable|null $e)

Ensure the chained job catch callbacks are invoked.

mixed
getRunningCommand()

Get the command currently being processed.

Details

at line 48
__construct(Dispatcher $dispatcher, Container $container)

Create a new handler instance.

Parameters

Dispatcher $dispatcher
Container $container

at line 57
void call(Job $job, array $data)

Handle the queued job.

Parameters

Job $job
array $data

Return Value

void

at line 102
protected mixed getCommand(array $data)

Get the command from the given payload.

Parameters

array $data

Return Value

mixed

Exceptions

RuntimeException

at line 120
protected mixed dispatchThroughMiddleware(Job $job, mixed $command)

Dispatch the given job / command through its specified middleware.

Parameters

Job $job
mixed $command

Return Value

mixed

at line 157
protected mixed resolveHandler(Job $job, mixed $command)

Resolve the handler for the given command.

Parameters

Job $job
mixed $command

Return Value

mixed

at line 174
protected mixed setJobInstanceIfNecessary(Job $job, mixed $instance)

Set the job instance of the given class if necessary.

Parameters

Job $job
mixed $instance

Return Value

mixed

at line 186
protected void ensureNextJobInChainIsDispatched(mixed $command)

Ensure the next job in the chain is dispatched if applicable.

Parameters

mixed $command

Return Value

void

at line 196
protected void ensureSuccessfulBatchJobIsRecorded(mixed $command)

Ensure the batch is notified of the successful job completion.

Parameters

mixed $command

Return Value

void

at line 212
protected bool uniqueJobLockShouldBeReleased(Job $job, mixed $command)

Determine if the unique job lock should be released.

Parameters

Job $job
mixed $command

Return Value

bool

at line 222
protected string getUniqueJobLockOwner(Job $job, mixed $command)

Resolve the unique lock owner carried by the command or its queued payload.

Parameters

Job $job
mixed $command

Return Value

string

at line 240
protected void ensureUniqueJobLockIsReleased(mixed $command, bool $onlyOwned = false, Job|null $job = null)

Ensure the lock for a unique job is released.

Parameters

mixed $command
bool $onlyOwned
Job|null $job

the queued job carrying ownership for commands without Queueable state

Return Value

void

at line 254
protected bool commandShouldBeDebounced(mixed $command)

Determine if the debounced command was superseded by a newer dispatch.

Parameters

mixed $command

Return Value

bool

at line 276
protected void deleteDebouncedJob(Job $job, mixed $command)

Handle a debounced job by firing an event and deleting it.

Parameters

Job $job
mixed $command

Return Value

void

at line 293
protected bool commandShouldBeUnique(mixed $command)

Determine if the given command should be unique.

Parameters

mixed $command

Return Value

bool

at line 302
protected bool commandShouldBeUniqueUntilProcessing(mixed $command)

Determine if the given command should be unique until processing begins.

Parameters

mixed $command

Return Value

bool

at line 311
protected void handleModelNotFound(Job $job, Throwable $e)

Handle a model not found exception.

Parameters

Job $job
Throwable $e

Return Value

void

at line 345
protected void ensureUniqueJobLockIsReleasedForMissingModel(Job|null $job, array $payload, bool $beforeProcessing)

Release the unique lock of a job whose command cannot be restored because its models are missing.

Parameters

Job|null $job
array $payload

the job's payload, or a partial payload containing only its data when the job is unavailable

bool $beforeProcessing

whether this attempt failed before its command began processing

Return Value

void

at line 394
protected bool ownerlessUniqueLockMayBeReleasedForMissingModel(Job|null $job, array $payload, bool $beforeProcessing)

Determine if an ownerless unique lock still belongs to a job whose models are missing.

Parameters

Job|null $job
array $payload

the job's payload, or a partial payload containing only its data when the job is unavailable

bool $beforeProcessing

whether this attempt failed before its command began processing

Return Value

bool

at line 420
protected void ensureUniqueJobLockIsReleasedViaContext()

Ensure the lock for a unique job is released via context.

This is required when we can't unserialize the job due to missing models.

Return Value

void

at line 453
protected void ensureSuccessfulBatchJobIsRecordedForMissingModel(Job $job, string $class)

Record a potentially batched job as successful when deleted because models were missing.

Parameters

Job $job
string $class

Return Value

void

at line 481
void failed(array $data, Throwable|null $e, string $uuid, Job|null $job = null)

Call the failed method on the job instance.

The exception that caused the failure will be passed.

Parameters

array $data
Throwable|null $e
string $uuid
Job|null $job

Return Value

void

at line 522
protected void ensureFailedBatchJobIsRecorded(string $uuid, mixed $command, Throwable|null $e)

Ensure the batch is notified of the failed job.

Parameters

string $uuid
mixed $command
Throwable|null $e

Return Value

void

at line 536
protected void ensureFailedBatchJobIsRecordedForMissingModel(string $uuid, array $data, Throwable|null $e)

Record a potentially batched job as failed when its models are missing.

Parameters

string $uuid
array $data
Throwable|null $e

Return Value

void

at line 556
protected void ensureChainCatchCallbacksAreInvoked(string $uuid, mixed $command, Throwable|null $e)

Ensure the chained job catch callbacks are invoked.

Parameters

string $uuid
mixed $command
Throwable|null $e

Return Value

void

at line 566
mixed getRunningCommand()

Get the command currently being processed.

Return Value

mixed