class Queue implements Queue, ClearableQueue (View source)

Traits

Properties

protected Job|null $processingJob

The currently processing job.

protected string|null $processingQueue

The queue for the currently processing job.

protected CarbonImmutable $processingJobStartedAt

The date the last job started processing.

Methods

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

__construct(Application $app, Queue $queue, Events $events, array $config)

Create a new Queue instance.

int
size(string|null $queue = null)

Get the size of the queue.

int
pendingSize(string|null $queue = null)

Get the number of pending jobs.

int
delayedSize(string|null $queue = null)

Get the number of delayed jobs.

int
reservedSize(string|null $queue = null)

Get the number of reserved jobs.

int|null
creationTimeOfOldestPendingJob(string|null $queue = null)

Get the creation timestamp of the oldest pending job, excluding delayed jobs.

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

Push a new job onto the queue.

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

Push a new job onto the queue.

mixed
pushRaw(string $payload, string|null $queue = null, array $options = [])

Push a raw payload onto the queue.

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

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

mixed
laterOn(string $queue, DateTimeInterface|DateInterval|int $delay, string|object $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.

Job|null
pop(string|null $queue = null)

Pop the next job off of the queue.

CloudJob|null
popFromAgent()

Long-poll the cloud-agent's runtime socket and wrap the next message in a CloudJob.

array|null
requestNextJobFromAgent()

Long-poll the agent's runtime socket (GET /next) for the next job.

void
reportJobStatusToAgent(string $messageId, string|null $receiptHandle, string $status, int|null $delay = null)

Report a job's terminal outcome back to the agent (POST /result).

agentUnreachable(string $message, Throwable|null $previous = null)

Build the exception for an unreachable agent, first flagging the running queue:work worker to stop so the pod restarts.

agentRequest()

Get a pending HTTP request bound to the agent's Unix runtime socket.

int
clear(string $queue)

Delete all of the jobs from the queue.

bool
usesAgent(string|null $queue = null)

Determine whether the next job should be received from the in-container cloud-agent.

string
workerQueue()

Get the queue the running queue:work worker is processing.

string
getConnectionName()

Get the connection name for the queue.

$this
setConnectionName(string $name)

Set the connection name for the queue.

$this
setConfig(array $config)

Set the queue configuration array.

array
getQueueableOptions(mixed $job, string|null $queue, string $payload, DateTimeInterface|DateInterval|int|null $delay = null)

Get the queueable options from the job.

void
finishProcessingJob(string $default = 'processed', CarbonImmutable|null $timestamp = null)

Finish processing the current job and emit a queue event.

CarbonImmutable}
processingJobDetails()

Last job details resolver.

finishQueueingJob(string $queue)

Handle jobs finishing being queued.

void
startProcessingJob(string|null $queue, Job|null $job)

Handle a job being popped.

string
normalizeQueue(string|null $queue)

Normalize the queue name.

mixed
__call(string $method, array $parameters)

Dynamically pass method calls to the underlying queue.

Details

protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

protected mixed forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

__construct(Application $app, Queue $queue, Events $events, array $config)

Create a new Queue instance.

Parameters

Application $app
Queue $queue
Events $events
array $config

int size(string|null $queue = null)

Get the size of the queue.

Parameters

string|null $queue

Return Value

int

int pendingSize(string|null $queue = null)

Get the number of pending jobs.

Parameters

string|null $queue

Return Value

int

int delayedSize(string|null $queue = null)

Get the number of delayed jobs.

Parameters

string|null $queue

Return Value

int

int reservedSize(string|null $queue = null)

Get the number of reserved jobs.

Parameters

string|null $queue

Return Value

int

int|null creationTimeOfOldestPendingJob(string|null $queue = null)

Get the creation timestamp of the oldest pending job, excluding delayed jobs.

Parameters

string|null $queue

Return Value

int|null

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

Push a new job onto the queue.

Parameters

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

Return Value

mixed

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

Push a new job onto the queue.

Parameters

string $queue
string|object $job
mixed $data

Return Value

mixed

mixed pushRaw(string $payload, string|null $queue = null, array $options = [])

Push a raw payload onto the queue.

Parameters

string $payload
string|null $queue
array $options

Return Value

mixed

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

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

Parameters

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

Return Value

mixed

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

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

Parameters

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

Return Value

mixed

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

Job|null pop(string|null $queue = null)

Pop the next job off of the queue.

Jobs come straight from SQS unless the cloud-agent is enabled.

When cloud-agent is enabled, we long-poll the agent's runtime socket instead.

Parameters

string|null $queue

Return Value

Job|null

protected CloudJob|null popFromAgent()

Long-poll the cloud-agent's runtime socket and wrap the next message in a CloudJob.

Return Value

CloudJob|null

protected array|null requestNextJobFromAgent()

Long-poll the agent's runtime socket (GET /next) for the next job.

Return Value

array|null

Exceptions

AgentUnreachableException

protected void reportJobStatusToAgent(string $messageId, string|null $receiptHandle, string $status, int|null $delay = null)

Report a job's terminal outcome back to the agent (POST /result).

Parameters

string $messageId
string|null $receiptHandle
string $status
int|null $delay

Return Value

void

Exceptions

RequestException
AgentUnreachableException

protected AgentUnreachableException agentUnreachable(string $message, Throwable|null $previous = null)

Build the exception for an unreachable agent, first flagging the running queue:work worker to stop so the pod restarts.

This release has no injectable LostConnectionDetector, so rather than teaching the worker to recognize the exception, flag the shared worker singleton directly. Its daemon loop then exits with a "lost connection" stop reason on the next tick and the process is restarted.

Parameters

string $message
Throwable|null $previous

Return Value

AgentUnreachableException

protected PendingRequest agentRequest()

Get a pending HTTP request bound to the agent's Unix runtime socket.

Return Value

PendingRequest

int clear(string $queue)

Delete all of the jobs from the queue.

Parameters

string $queue

Return Value

int

protected bool usesAgent(string|null $queue = null)

Determine whether the next job should be received from the in-container cloud-agent.

Parameters

string|null $queue

Return Value

bool

protected string workerQueue()

Get the queue the running queue:work worker is processing.

Return Value

string

string getConnectionName()

Get the connection name for the queue.

Return Value

string

$this setConnectionName(string $name)

Set the connection name for the queue.

Parameters

string $name

Return Value

$this

$this setConfig(array $config)

Set the queue configuration array.

Parameters

array $config

Return Value

$this

array getQueueableOptions(mixed $job, string|null $queue, string $payload, DateTimeInterface|DateInterval|int|null $delay = null)

Get the queueable options from the job.

Parameters

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

Return Value

array

void finishProcessingJob(string $default = 'processed', CarbonImmutable|null $timestamp = null)

Finish processing the current job and emit a queue event.

Parameters

string $default
CarbonImmutable|null $timestamp

Return Value

void

CarbonImmutable} processingJobDetails()

Last job details resolver.

Return Value

CarbonImmutable}

finishQueueingJob(string $queue)

Handle jobs finishing being queued.

Parameters

string $queue

protected void startProcessingJob(string|null $queue, Job|null $job)

Handle a job being popped.

Parameters

string|null $queue
Job|null $job

Return Value

void

string normalizeQueue(string|null $queue)

Normalize the queue name.

Parameters

string|null $queue

Return Value

string

mixed __call(string $method, array $parameters)

Dynamically pass method calls to the underlying queue.

Parameters

string $method
array $parameters

Return Value

mixed

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.