DeferredQueue
class DeferredQueue extends CoroutineQueue
Traits
Properties
| protected Container | $container | The IoC container instance. |
from Queue |
| protected string | $connectionName | The connection name for the queue. |
from Queue |
| protected array | $config | The original configuration for the queue. |
from Queue |
| protected bool | $dispatchAfterCommit | Indicates that jobs should be dispatched after the open parent database transactions have committed. |
from Queue |
| protected null|Queue): mixed): mixed | $afterCommitDispatcher | Dispatch an after-commit operation through its live queue owner. |
from Queue |
| static protected callable[] | $createPayloadCallbacks | The create payload callbacks. |
from Queue |
| protected string | $default | The name of the default queue. |
|
| protected null|callable | $exceptionCallback | The exception callback that should be used for handling uncaught exceptions. |
from CoroutineQueue |
| protected Timer | $timer | The timer used to schedule delayed jobs. |
from CoroutineQueue |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Get a configuration value from an attribute, falling back to a property.
Extract the value from an attribute instance.
Get an instance of the given attribute class from the target class or its parents.
Determine if a property declared on a child class overrides an inherited attribute.
Resolve the default connection name for a given queueable instance.
Resolve the default queue name for a given queueable instance.
Get the container that owns the queue routes.
Push a new job onto the queue.
Push a new job onto a specific queue after (n) seconds.
Push an array of jobs onto the queue.
Create a payload string from the given job and data.
Create a payload array from the given job and data.
Create a payload for an object-based queue handler.
Get the maximum number of attempts for an object-based queue handler.
Get the expiration timestamp for an object-based queue handler.
Create a typical, string based queue payload array.
Register a callback to be executed when creating job payloads.
Create the given payload using any registered payload hooks.
Set the dispatcher for after-commit queue operations.
Enqueue a job using the given callback.
Defer an enqueue operation until the applicable transaction commits.
Defer a batch enqueue operation until the applicable transaction commits.
Enqueue a job immediately using the given callback.
Finalize an encoded payload immediately before queueing.
Partition jobs by whether they should be deferred until the active transaction commits.
Determine if the job should be dispatched after the open parent database transactions have committed.
Register a transaction rollback callback that releases the job's locks.
Create a callback that releases the job's locks.
Mark a job's dispatch locks as accepted by the queue.
Raise the job queueing event.
Raise the job queueing failed event.
Raise the job queued event.
Normalize an enum queue name without applying defaults or forwarding.
Create a new coroutine queue instance.
Get the number of reserved jobs.
Get the pending jobs for the given queue.
Get the delayed jobs for the given queue.
Get the reserved jobs for the given queue.
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
Push a new job onto the queue.
Execute a given job synchronously.
Schedule a serialized job for coroutine execution.
Raise the job attempted event.
Raise the exception occurred queue job event.
Handle an exception that occurred while processing a job.
Push a raw payload onto the queue.
Push a new job onto the queue after (n) seconds.
Set the exception callback for the coroutine queue.
Create and schedule a delayed job.
Schedule the timer that will execute the job after the delay.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 47
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 63
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 71
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
in
ReadsClassAttributes at line 17
protected mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)
Get a configuration value from an attribute, falling back to a property.
in
ReadsClassAttributes at line 46
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
in
ReadsClassAttributes at line 58
protected object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)
Get an instance of the given attribute class from the target class or its parents.
in
ReadsClassAttributes at line 74
protected bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)
Determine if a property declared on a child class overrides an inherited attribute.
in
ResolvesQueueRoutes at line 19
string|null
resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)
Resolve the default connection name for a given queueable instance.
in
ResolvesQueueRoutes at line 27
string|null
resolveQueueFromQueueRoute(object $queueable)
Resolve the default queue name for a given queueable instance.
in
ResolvesQueueRoutes at line 35
protected QueueRoutes
queueRoutes()
Get the queue routes manager instance.
in
ResolvesQueueRoutes at line 48
protected Container
queueRoutesContainer()
Get the container that owns the queue routes.
in
Queue at line 89
mixed
pushOn(UnitEnum|string|null $queue, object|string $job, mixed $data = '')
Push a new job onto the queue.
in
Queue at line 97
mixed
laterOn(UnitEnum|string|null $queue, DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '')
Push a new job onto a specific queue after (n) seconds.
in
Queue at line 105
mixed
bulk(array $jobs, mixed $data = '', UnitEnum|string|null $queue = null)
Push an array of jobs onto the queue.
in
Queue at line 125
protected mixed
getJobDelay(object|string $job)
Get the delay configured on the given job.
in
Queue at line 139
protected string
createPayload(array|object|string $job, string|null $queue, mixed $data = '', DateInterval|DateTimeInterface|int|null $delay = null)
Create a payload string from the given job and data.
in
Queue at line 172
protected array
createPayloadArray(array|object|string $job, string|null $queue, mixed $data = '')
Create a payload array from the given job and data.
in
Queue at line 184
protected array
createObjectPayload(object $job, string|null $queue)
Create a payload for an object-based queue handler.
in
Queue at line 252
protected string
getDisplayName(object $job)
Get the display name for the given job.
in
Queue at line 262
mixed
getJobTries(mixed $job)
Get the maximum number of attempts for an object-based queue handler.
in
Queue at line 276
mixed
getJobBackoff(mixed $job)
Get the backoff for an object-based queue handler.
in
Queue at line 296
mixed
getJobExpiration(mixed $job)
Get the expiration timestamp for an object-based queue handler.
in
Queue at line 312
protected bool
jobShouldBeEncrypted(object $job)
Determine if the job should be encrypted.
in
Queue at line 324
protected array
createStringPayload(array|string $job, string|null $queue, mixed $data)
Create a typical, string based queue payload array.
in
Queue at line 347
static void
createPayloadUsing(callable|null $callback)
Register a callback to be executed when creating job payloads.
Boot-only. The callback persists in a static property for the worker lifetime and runs on every subsequent payload creation across all coroutines. Passing null clears the registry.
in
Queue at line 359
protected array
withCreatePayloadHooks(string|null $queue, array $payload)
Create the given payload using any registered payload hooks.
in
Queue at line 375
Queue
setAfterCommitDispatcher(Closure|null $dispatcher)
Set the dispatcher for after-commit queue operations.
in
Queue at line 390
protected mixed
enqueueUsing(object|string $job, string $payload, string|null $queue, DateInterval|DateTimeInterface|int|null $delay, callable $callback)
Enqueue a job using the given callback.
The callback receives the queue that owns the operation first so deferred pooled dispatch never retains a borrowed queue.
in
Queue at line 417
protected void
deferEnqueueAfterCommit(DatabaseTransactionsManager $transactions, object|string $job, Closure $enqueue)
Defer an enqueue operation until the applicable transaction commits.
in
Queue at line 431
protected void
deferBatchEnqueueAfterCommit(DatabaseTransactionsManager $transactions, array $jobs, Closure $enqueue)
Defer a batch enqueue operation until the applicable transaction commits.
in
Queue at line 480
protected mixed
enqueueNow(object|string $job, string $payload, string|null $queue, DateInterval|DateTimeInterface|int|null $delay, callable $callback)
Enqueue a job immediately using the given callback.
in
Queue at line 505
protected string
finalizePayloadForQueueing(string|null $queue, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)
Finalize an encoded payload immediately before queueing.
in
Queue at line 540
protected array
partitionJobsByAfterCommit(array $jobs, DatabaseTransactionsManager|null $transactions)
Partition jobs by whether they should be deferred until the active transaction commits.
in
Queue at line 559
protected bool
shouldDispatchAfterCommit(object|string $job)
Determine if the job should be dispatched after the open parent database transactions have committed.
in
Queue at line 575
protected void
addJobRollbackCallback(DatabaseTransactionsManager $transactions, object|string $job)
Register a transaction rollback callback that releases the job's locks.
in
Queue at line 587
protected Closure|null
createJobRollbackCallback(object|string $job)
Create a callback that releases the job's locks.
in
Queue at line 603
protected void
acceptDispatchLocks(object|string $job)
Mark a job's dispatch locks as accepted by the queue.
in
Queue at line 615
protected void
raiseJobQueueingEvent(string|null $queue, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)
Raise the job queueing event.
in
Queue at line 636
protected void
raiseJobQueueingFailedEvent(string|null $queue, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay, Throwable $exception)
Raise the job queueing failed event.
in
Queue at line 657
protected void
raiseJobQueuedEvent(string|null $queue, mixed $jobId, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)
Raise the job queued event.
in
Queue at line 676
protected string|null
normalizeQueue(UnitEnum|string|null $queue)
Normalize an enum queue name without applying defaults or forwarding.
in
Queue at line 684
protected string
resolveQueue(string $queue)
Get the routed queue name for the given queue.
in
Queue at line 700
string
getConnectionName()
Get the connection name for the queue.
in
Queue at line 712
Queue
setConnectionName(string $name)
Set the connection name for the queue.
Boot or tests only. Queue connection instances are cached on QueueManager; runtime use races across coroutines and changes every concurrent dispatch through this connection.
in
Queue at line 722
array
getConfig()
Get the queue configuration array.
in
Queue at line 734
Queue
setConfig(array $config)
Set the queue configuration array.
Boot or tests only. Queue connection instances are cached on QueueManager; runtime use races across coroutines and changes every concurrent dispatch through this connection.
in
Queue at line 744
Container
getContainer()
Get the container instance being used by the connection.
in
Queue at line 756
Queue
setContainer(Container $container)
Set the IoC container instance.
Boot or tests only. Queue connection instances are cached on QueueManager; runtime use races across coroutines and changes every concurrent dispatch through this connection.
in
Queue at line 766
static void
flushState()
Flush all static state.
in
CoroutineQueue at line 35
__construct(bool $dispatchAfterCommit = false, Timer|null $timer = null)
Create a new coroutine queue instance.
in
SyncQueue at line 41
int
size(UnitEnum|string|null $queue = null)
Get the size of the queue.
in
SyncQueue at line 49
int
pendingSize(UnitEnum|string|null $queue = null)
Get the number of pending jobs.
in
SyncQueue at line 57
int
delayedSize(UnitEnum|string|null $queue = null)
Get the number of delayed jobs.
in
SyncQueue at line 65
int
reservedSize(UnitEnum|string|null $queue = null)
Get the number of reserved jobs.
in
SyncQueue at line 73
int
totalSize()
Get the number of jobs across every queue.
in
SyncQueue at line 81
int
totalPendingSize()
Get the number of pending jobs across every queue.
in
SyncQueue at line 89
int
totalDelayedSize()
Get the number of delayed jobs across every queue.
in
SyncQueue at line 97
int
totalReservedSize()
Get the number of reserved jobs across every queue.
in
SyncQueue at line 105
Collection
pendingJobs(UnitEnum|string|null $queue = null)
Get the pending jobs for the given queue.
in
SyncQueue at line 113
Collection
delayedJobs(UnitEnum|string|null $queue = null)
Get the delayed jobs for the given queue.
in
SyncQueue at line 121
Collection
reservedJobs(UnitEnum|string|null $queue = null)
Get the reserved jobs for the given queue.
in
SyncQueue at line 129
Collection
allPendingJobs()
Get all pending jobs across every queue.
in
SyncQueue at line 137
Collection
allDelayedJobs()
Get all delayed jobs across every queue.
in
SyncQueue at line 145
Collection
allReservedJobs()
Get all reserved jobs across every queue.
in
SyncQueue at line 153
int|null
creationTimeOfOldestPendingJob(UnitEnum|string|null $queue = null)
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
in
SyncQueue at line 163
mixed
push(object|string $job, mixed $data = '', UnitEnum|string|null $queue = null)
Push a new job onto the queue.
in
SyncQueue at line 193
protected int
executeJob(object|string $job, mixed $data = '', string|null $queue = null)
Execute a given job synchronously.
in
CoroutineQueue at line 137
protected int
executePayload(string $payload, string|null $queue = null)
Schedule a serialized job for coroutine execution.
in
SyncQueue at line 244
protected SyncJob
resolveJob(string $payload, string|null $queue)
Resolve a Sync job instance.
in
SyncQueue at line 254
protected void
raiseBeforeJobEvent(Job $job)
Raise the before queue job event.
in
SyncQueue at line 269
protected void
raiseAfterJobEvent(Job $job)
Raise the after queue job event.
in
SyncQueue at line 284
protected void
raiseJobAttemptedEvent(Job $job, Throwable|null $exceptionOccurred = null)
Raise the job attempted event.
in
SyncQueue at line 299
protected void
raiseExceptionOccurredJobEvent(Job $job, Throwable $e)
Raise the exception occurred queue job event.
in
SyncQueue at line 316
protected void
handleException(Job $queueJob, Throwable $e)
Handle an exception that occurred while processing a job.
in
SyncQueue at line 328
mixed
pushRaw(string $payload, UnitEnum|string|null $queue = null, array $options = [])
Push a raw payload onto the queue.
in
CoroutineQueue at line 46
mixed
later(DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '', UnitEnum|string|null $queue = null)
Push a new job onto the queue after (n) seconds.
in
SyncQueue at line 344
Job|null
pop(UnitEnum|string|null $queue = null)
Pop the next job off of the queue.
in
CoroutineQueue at line 77
CoroutineQueue
setExceptionCallback(callable|null $callback)
Set the exception callback for the coroutine queue.
Boot-only. The callback persists on the cached queue connection for the worker lifetime and handles every subsequent coroutine queue exception.
in
CoroutineQueue at line 87
protected int
scheduleJob(DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data, string|null $queue)
Create and schedule a delayed job.
in
CoroutineQueue at line 111
protected int
scheduleTimer(DateInterval|DateTimeInterface|int $delay, string $payload, string|null $queue, array|null $snapshot)
Schedule the timer that will execute the job after the delay.
Skips execution when the worker is closing — pending delayed jobs are dropped rather than racing against shutdown cleanup. Devs needing durability across worker restarts should use a persistent queue.
at line 20
protected void
scheduleExecution(Closure $execution)
Defer the given execution callback.