abstract class Queue

Traits

Properties

protected Container $container

The IoC container instance.

protected string $connectionName

The connection name for the queue.

protected array $config

The original configuration for the queue.

protected bool $dispatchAfterCommit

Indicates that jobs should be dispatched after all database transactions have committed.

protected null|Queue): mixed): mixed $afterCommitDispatcher

Dispatch an after-commit operation through its live queue owner.

static protected callable[] $createPayloadCallbacks

The create payload callbacks.

Methods

int
secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

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.

mixed
extractAttributeValue(object $instance)

Extract the value from an attribute instance.

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.

bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)

Determine if a property declared on a child class overrides an inherited attribute.

mixed
pushOn(string|null $queue, object|string $job, mixed $data = '')

Push a new job onto the queue.

mixed
laterOn(string|null $queue, DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '')

Push a new job onto a specific queue after (n) seconds.

mixed
bulk(array $jobs, mixed $data = '', string|null $queue = null)

Push an array of jobs onto the queue.

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.

array
createPayloadArray(array|object|string $job, string|null $queue, mixed $data = '')

Create a payload array from the given job and data.

array
createObjectPayload(object $job, string|null $queue)

Create a payload for an object-based queue handler.

string
getDisplayName(object $job)

Get the display name for the given job.

mixed
getJobTries(mixed $job)

Get the maximum number of attempts for an object-based queue handler.

mixed
getJobBackoff(mixed $job)

Get the backoff for an object-based queue handler.

mixed
getJobExpiration(mixed $job)

Get the expiration timestamp for an object-based queue handler.

bool
jobShouldBeEncrypted(object $job)

Determine if the job should be encrypted.

array
createStringPayload(array|string $job, string|null $queue, mixed $data)

Create a typical, string based queue payload array.

static void
createPayloadUsing(callable|null $callback)

Register a callback to be executed when creating job payloads.

array
withCreatePayloadHooks(string|null $queue, array $payload)

Create the given payload using any registered payload hooks.

setAfterCommitDispatcher(Closure|null $dispatcher)

Set the dispatcher for after-commit queue operations.

mixed
enqueueUsing(object|string $job, string $payload, string|null $queue, DateInterval|DateTimeInterface|int|null $delay, callable $callback)

Enqueue a job using the given callback.

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.

bool
shouldDispatchAfterCommit(object|string $job)

Determine if the job should be dispatched after all database transactions have committed.

void
addUniqueJobRollbackCallback(DatabaseTransactionsManager $transactions, object|string $job)

Register a transaction rollback callback that releases the unique lock for the given job.

void
addDebouncedJobRollbackCallback(DatabaseTransactionsManager $transactions, object|string $job)

Register a transaction rollback callback that releases the debounce token for the given job.

void
raiseJobQueueingEvent(string|null $queue, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)

Raise the job queueing event.

void
raiseJobQueuedEvent(string|null $queue, mixed $jobId, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)

Raise the job queued event.

string
getConnectionName()

Get the connection name for the queue.

setConnectionName(string $name)

Set the connection name for the queue.

array
getConfig()

Get the queue configuration array.

setConfig(array $config)

Set the queue configuration array.

getContainer()

Get the container instance being used by the connection.

setContainer(Container $container)

Set the IoC container instance.

static void
flushState()

Flush all static state.

Details

in InteractsWithTime at line 17
protected int secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateInterval|DateTimeInterface|int $delay

Return Value

int

in InteractsWithTime at line 29
protected int availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

int

in InteractsWithTime at line 41
protected DateTimeInterface|int parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

DateTimeInterface|int

in InteractsWithTime at line 57
protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

in InteractsWithTime at line 65
protected string runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float|null $endTime

Return Value

string

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.

Parameters

object $target
string $attributeClass
string|null $property
mixed $default

Return Value

mixed

protected mixed extractAttributeValue(object $instance)

Extract the value from an attribute instance.

Parameters

object $instance

Return Value

mixed

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.

Parameters

object $target
string $attributeClass
ReflectionClass|null $declaringClass

Return Value

object|null

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.

Parameters

object $target
ReflectionClass $reflection
string|null $property
ReflectionClass $attributeDeclaringClass

Return Value

bool

at line 82
mixed pushOn(string|null $queue, object|string $job, mixed $data = '')

Push a new job onto the queue.

Parameters

string|null $queue
object|string $job
mixed $data

Return Value

mixed

at line 91
mixed laterOn(string|null $queue, DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '')

Push a new job onto a specific queue after (n) seconds.

Parameters

string|null $queue
DateInterval|DateTimeInterface|int $delay
object|string $job
mixed $data

Return Value

mixed

at line 100
mixed bulk(array $jobs, mixed $data = '', string|null $queue = null)

Push an array of jobs onto the queue.

Parameters

array $jobs
mixed $data
string|null $queue

Return Value

mixed

at line 117
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.

Parameters

array|object|string $job
string|null $queue
mixed $data
DateInterval|DateTimeInterface|int|null $delay

Return Value

string

Exceptions

InvalidPayloadException

at line 150
protected array createPayloadArray(array|object|string $job, string|null $queue, mixed $data = '')

Create a payload array from the given job and data.

Parameters

array|object|string $job
string|null $queue
mixed $data

Return Value

array

at line 160
protected array createObjectPayload(object $job, string|null $queue)

Create a payload for an object-based queue handler.

Parameters

object $job
string|null $queue

Return Value

array

at line 214
protected string getDisplayName(object $job)

Get the display name for the given job.

Parameters

object $job

Return Value

string

at line 223
mixed getJobTries(mixed $job)

Get the maximum number of attempts for an object-based queue handler.

Parameters

mixed $job

Return Value

mixed

at line 237
mixed getJobBackoff(mixed $job)

Get the backoff for an object-based queue handler.

Parameters

mixed $job

Return Value

mixed

at line 257
mixed getJobExpiration(mixed $job)

Get the expiration timestamp for an object-based queue handler.

Parameters

mixed $job

Return Value

mixed

at line 272
protected bool jobShouldBeEncrypted(object $job)

Determine if the job should be encrypted.

Parameters

object $job

Return Value

bool

at line 284
protected array createStringPayload(array|string $job, string|null $queue, mixed $data)

Create a typical, string based queue payload array.

Parameters

array|string $job
string|null $queue
mixed $data

Return Value

array

at line 307
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.

Parameters

callable|null $callback

Return Value

void

at line 319
protected array withCreatePayloadHooks(string|null $queue, array $payload)

Create the given payload using any registered payload hooks.

Parameters

string|null $queue
array $payload

Return Value

array

at line 335
Queue setAfterCommitDispatcher(Closure|null $dispatcher)

Set the dispatcher for after-commit queue operations.

Parameters

Closure|null $dispatcher

Return Value

Queue

at line 350
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.

Parameters

object|string $job
string $payload
string|null $queue
DateInterval|DateTimeInterface|int|null $delay
callable $callback

Return Value

mixed

at line 388
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.

Parameters

object|string $job
string $payload
string|null $queue
DateInterval|DateTimeInterface|int|null $delay
callable $callback

Return Value

mixed

at line 402
protected bool shouldDispatchAfterCommit(object|string $job)

Determine if the job should be dispatched after all database transactions have committed.

Parameters

object|string $job

Return Value

bool

at line 418
protected void addUniqueJobRollbackCallback(DatabaseTransactionsManager $transactions, object|string $job)

Register a transaction rollback callback that releases the unique lock for the given job.

Parameters

DatabaseTransactionsManager $transactions
object|string $job

Return Value

void

at line 434
protected void addDebouncedJobRollbackCallback(DatabaseTransactionsManager $transactions, object|string $job)

Register a transaction rollback callback that releases the debounce token for the given job.

Parameters

DatabaseTransactionsManager $transactions
object|string $job

Return Value

void

at line 452
protected void raiseJobQueueingEvent(string|null $queue, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)

Raise the job queueing event.

Parameters

string|null $queue
object|string $job
string $payload
DateInterval|DateTimeInterface|int|null $delay

Return Value

void

at line 473
protected void raiseJobQueuedEvent(string|null $queue, mixed $jobId, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)

Raise the job queued event.

Parameters

string|null $queue
mixed $jobId
object|string $job
string $payload
DateInterval|DateTimeInterface|int|null $delay

Return Value

void

at line 492
string getConnectionName()

Get the connection name for the queue.

Return Value

string

at line 504
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.

Parameters

string $name

Return Value

Queue

at line 514
array getConfig()

Get the queue configuration array.

Return Value

array

at line 526
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.

Parameters

array $config

Return Value

Queue

at line 536
Container getContainer()

Get the container instance being used by the connection.

Return Value

Container

at line 548
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.

Parameters

Container $container

Return Value

Queue

at line 558
static void flushState()

Flush all static state.

Return Value

void