class QueueManager implements Factory, Monitor mixin Queue

Traits

Hosts must declare a protected array $poolableDrivers containing their default poolable drivers.

Properties

protected Closure> $releaseCallbacks from  HasPoolProxy
protected array $connections

The array of resolved queue connections.

protected array $connectors

The array of resolved queue connectors.

protected array $poolableDrivers

The array of drivers which will be wrapped as pool proxies.

protected QueuePoolProxy>> $poolProxyClasses

The pool proxy classes for drivers with supplemental queue capabilities.

Methods

mixed
createPoolProxy(string $driver, Closure $createCallback, PoolDefinition $definition, string $proxyClass)

Create a pool proxy for an immutable definition.

poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)

Build a namespaced pool definition for a pooled resource.

poolFactory()

Get the shared object-pool factory.

setReleaseCallback(string $driver, Closure $callback)

Set the release callback for a pooled driver.

Closure|null
getReleaseCallback(string $driver)

Get the release callback for a pooled driver.

addPoolableDriver(string $driver)

Add a driver to the poolable-driver list.

removePoolableDriver(string $driver)

Remove a driver from the poolable-driver list.

array
getPoolableDrivers()

Get the poolable-driver list.

setPoolableDrivers(array $poolableDrivers)

Set the poolable-driver list.

string|null
resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)

Resolve the default connection name for a given queueable instance.

string|null
resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

queueRoutes()

Get the queue routes manager instance.

queueRoutesContainer()

Get the container that owns the queue routes.

__construct(Container $app)

Create a new queue manager instance.

void
before(mixed $callback)

Register an event listener for the before job event.

void
after(mixed $callback)

Register an event listener for the after job event.

void
exceptionOccurred(mixed $callback)

Register an event listener for the exception occurred job event.

void
looping(mixed $callback)

Register an event listener for the daemon queue loop.

void
failing(mixed $callback)

Register an event listener for the failed job event.

void
starting(mixed $callback)

Register an event listener for the daemon queue starting.

void
stopping(mixed $callback)

Register an event listener for the daemon queue stopping.

void
route(array|string $class, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)

Register the default queue route for a given class.

void
forward(array|string|UnitEnum $queue, UnitEnum|string|null $to = null, UnitEnum|string|null $connection = null)

Forward the given queue to another queue and/or connection.

void
pause(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection.

void
pauseFor(UnitEnum|string $queue, DateInterval|DateTimeInterface|int $ttl, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection for a given amount of time.

void
pauseAll()

Pause job processing for all queues on all connections.

void
resume(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Resume a paused queue by its name and connection.

void
resumeAll()

Resume job processing for all queues on all connections.

bool
isPaused(string $queue, string|null $connection = null)

Determine if a queue is paused.

array
getPausedQueues(array $queues, string|null $connection = null)

Determine which of the given queues are currently paused.

void
withoutInterruptionPolling()

Indicate that queue workers should not poll for restart or pause signals.

bool
connected(UnitEnum|string|null $name = null)

Determine if the driver is connected.

connection(UnitEnum|string|null $name = null)

Resolve a queue connection instance.

resolve(string $name)

Resolve a queue connection.

getConnector(string $driver)

Get the connector for a given driver.

void
extend(string $driver, Closure $resolver)

Add a queue connection resolver.

void
addConnector(string $driver, Closure $resolver)

Add a queue connection resolver.

array|null
getConfig(string $name)

Get the queue connection configuration.

string
getDefaultDriver()

Get the name of the default queue connection.

void
setDefaultDriver(UnitEnum|string $name)

Set the name of the default queue connection.

string
getName(string|null $connection = null)

Get the full name for the given connection.

void
purge(string|null $name = null)

Disconnect a queue connection and close its shared resource pool.

getApplication()

Get the application instance used by the manager.

setApplication(Container $app)

Set the application instance used by the manager.

void
createPayloadUsing(callable|null $callback)

Register a callback to be executed when creating job payloads.

mixed
__call(string $method, array $parameters)

Dynamically pass calls to the default connection.

Details

in HasPoolProxy at line 27
protected mixed createPoolProxy(string $driver, Closure $createCallback, PoolDefinition $definition, string $proxyClass)

Create a pool proxy for an immutable definition.

Parameters

string $driver
Closure $createCallback
PoolDefinition $definition
string $proxyClass

Return Value

mixed

in HasPoolProxy at line 48
protected PoolDefinition poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)

Build a namespaced pool definition for a pooled resource.

Parameters

string $resource
array $poolConfig
array $fingerprintSource

Return Value

PoolDefinition

at line 481
protected Factory poolFactory()

Get the shared object-pool factory.

Return Value

Factory

in HasPoolProxy at line 74
HasPoolProxy setReleaseCallback(string $driver, Closure $callback)

Set the release callback for a pooled driver.

Boot-only. The callback persists on the manager for the worker lifetime and is captured by every subsequently created proxy for the driver.

Parameters

string $driver
Closure $callback

Return Value

HasPoolProxy

in HasPoolProxy at line 84
Closure|null getReleaseCallback(string $driver)

Get the release callback for a pooled driver.

Parameters

string $driver

Return Value

Closure|null

in HasPoolProxy at line 96
HasPoolProxy addPoolableDriver(string $driver)

Add a driver to the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

string $driver

Return Value

HasPoolProxy

in HasPoolProxy at line 112
HasPoolProxy removePoolableDriver(string $driver)

Remove a driver from the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

string $driver

Return Value

HasPoolProxy

in HasPoolProxy at line 129
array getPoolableDrivers()

Get the poolable-driver list.

Return Value

array

in HasPoolProxy at line 141
HasPoolProxy setPoolableDrivers(array $poolableDrivers)

Set the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

array $poolableDrivers

Return Value

HasPoolProxy

string|null resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)

Resolve the default connection name for a given queueable instance.

Parameters

object $queueable
UnitEnum|string|null $queue

the caller-selected queue, overriding the queueable's queue when resolving a forwarded connection

Return Value

string|null

string|null resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

Parameters

object $queueable

Return Value

string|null

protected QueueRoutes queueRoutes()

Get the queue routes manager instance.

Return Value

QueueRoutes

at line 195
protected Container queueRoutesContainer()

Get the container that owns the queue routes.

Return Value

Container

at line 77
__construct(Container $app)

Create a new queue manager instance.

Parameters

Container $app

at line 88
void before(mixed $callback)

Register an event listener for the before job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 100
void after(mixed $callback)

Register an event listener for the after job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 112
void exceptionOccurred(mixed $callback)

Register an event listener for the exception occurred job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 124
void looping(mixed $callback)

Register an event listener for the daemon queue loop.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 136
void failing(mixed $callback)

Register an event listener for the failed job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 148
void starting(mixed $callback)

Register an event listener for the daemon queue starting.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 160
void stopping(mixed $callback)

Register an event listener for the daemon queue stopping.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 174
void route(array|string $class, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)

Register the default queue route for a given class.

Boot-only. The route persists on the singleton QueueRoutes registry for the worker lifetime and affects every subsequent dispatch of that class.

Parameters

array|string $class
UnitEnum|string|null $queue
UnitEnum|string|null $connection

Return Value

void

at line 187
void forward(array|string|UnitEnum $queue, UnitEnum|string|null $to = null, UnitEnum|string|null $connection = null)

Forward the given queue to another queue and/or connection.

Boot-only. Forwards persist on the singleton QueueRoutes registry for the worker lifetime and affect every subsequent dispatch and queue operation.

Parameters

array|string|UnitEnum $queue
UnitEnum|string|null $to
UnitEnum|string|null $connection

Return Value

void

at line 203
void pause(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection.

Parameters

UnitEnum|string $queue
UnitEnum|string|null $connection

Return Value

void

at line 225
void pauseFor(UnitEnum|string $queue, DateInterval|DateTimeInterface|int $ttl, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection for a given amount of time.

Parameters

UnitEnum|string $queue
DateInterval|DateTimeInterface|int $ttl
UnitEnum|string|null $connection

Return Value

void

at line 247
void pauseAll()

Pause job processing for all queues on all connections.

Return Value

void

at line 265
void resume(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Resume a paused queue by its name and connection.

Parameters

UnitEnum|string $queue
UnitEnum|string|null $connection

Return Value

void

at line 289
void resumeAll()

Resume job processing for all queues on all connections.

Queues paused individually are not affected.

Return Value

void

at line 307
bool isPaused(string $queue, string|null $connection = null)

Determine if a queue is paused.

Parameters

string $queue
string|null $connection

Return Value

bool

at line 321
array getPausedQueues(array $queues, string|null $connection = null)

Determine which of the given queues are currently paused.

Parameters

array $queues
string|null $connection

Return Value

array

at line 351
void withoutInterruptionPolling()

Indicate that queue workers should not poll for restart or pause signals.

Boot-only. Mutates process-global worker flags; runtime use races across coroutines and changes every concurrent worker pause or restart check.

Return Value

void

at line 360
bool connected(UnitEnum|string|null $name = null)

Determine if the driver is connected.

Parameters

UnitEnum|string|null $name

Return Value

bool

at line 376
Queue connection(UnitEnum|string|null $name = null)

Resolve a queue connection instance.

Parameters

UnitEnum|string|null $name

Return Value

Queue

at line 401
protected Queue resolve(string $name)

Resolve a queue connection.

Parameters

string $name

Return Value

Queue

Exceptions

InvalidArgumentException

at line 435
protected ConnectorInterface getConnector(string $driver)

Get the connector for a given driver.

Parameters

string $driver

Return Value

ConnectorInterface

Exceptions

InvalidArgumentException

at line 450
void extend(string $driver, Closure $resolver)

Add a queue connection resolver.

Boot-only. The resolver persists in the singleton's connectors array for the worker lifetime and applies to every subsequent connection.

Parameters

string $driver
Closure $resolver

Return Value

void

at line 461
void addConnector(string $driver, Closure $resolver)

Add a queue connection resolver.

Boot-only. The resolver persists in the singleton's connectors array for the worker lifetime and applies to every subsequent connection.

Parameters

string $driver
Closure $resolver

Return Value

void

at line 469
protected array|null getConfig(string $name)

Get the queue connection configuration.

Parameters

string $name

Return Value

array|null

at line 489
string getDefaultDriver()

Get the name of the default queue connection.

Return Value

string

at line 499
void setDefaultDriver(UnitEnum|string $name)

Set the name of the default queue connection.

Boot-only. Mutates process-global config; per-request use races across coroutines.

Parameters

UnitEnum|string $name

Return Value

void

at line 509
string getName(string|null $connection = null)

Get the full name for the given connection.

Parameters

string|null $connection

Return Value

string

at line 523
void purge(string|null $name = null)

Disconnect a queue connection and close its shared resource pool.

Boot or tests only, plus operational recovery of broken pooled resources. Other connections sharing the pool transparently acquire a fresh pool on their next operation.

Parameters

string|null $name

Return Value

void

at line 559
Container getApplication()

Get the application instance used by the manager.

Return Value

Container

at line 571
QueueManager setApplication(Container $app)

Set the application instance used by the manager.

Tests only. Swaps the container reference on the singleton and on every cached queue connection; per-request use races across coroutines and breaks every concurrent dispatch.

Parameters

Container $app

Return Value

QueueManager

at line 596
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 604
mixed __call(string $method, array $parameters)

Dynamically pass calls to the default connection.

Parameters

string $method
array $parameters

Return Value

mixed