Worker

class Worker (View source)

Properties

protected QueueManager $manager The queue manager instance.
protected FailedJobProviderInterface $failer The failed job provider implementation.
protected Dispatcher $events The event dispatcher instance.
protected Repository $cache The cache repository implementation.
protected Handler $exceptions The exception handler instance.

Methods

void __construct(QueueManager $manager, FailedJobProviderInterface $failer = null, Dispatcher $events = null)

Create a new queue worker.

array daemon(string $connectionName, string $queue = null, int $delay, int $memory = 128, int $sleep = 3, int $maxTries)

Listen to the given queue in a loop.

void runNextJobForDaemon(string $connectionName, string $queue, int $delay, int $sleep, int $maxTries)

Run the next job for the daemon worker.

bool daemonShouldRun()

Determine if the daemon should process on this iteration.

array pop(string $connectionName, string $queue = null, int $delay, int $sleep = 3, int $maxTries)

Listen to the given queue.

Job|null getNextJob(Queue $connection, string $queue)

Get the next job from the queue connection.

void process(string $connection, Job $job, int $maxTries, int $delay)

Process a given job from the queue.

array logFailedJob(string $connection, Job $job)

Log a failed job into storage.

void raiseFailedJobEvent(string $connection, Job $job)

Raise the failed queue job event.

bool memoryExceeded(int $memoryLimit)

Determine if the memory limit has been exceeded.

void stop()

Stop listening and bail out of the script.

void sleep(int $seconds)

Sleep the script for a given number of seconds.

int|null getTimestampOfLastQueueRestart()

Get the last queue restart timestamp, or null.

bool queueShouldRestart(int|null $lastRestart)

Determine if the queue worker should restart.

void setDaemonExceptionHandler(Handler $handler)

Set the exception handler to use in Daemon mode.

void setCache(Repository $cache)

Set the cache repository implementation.

QueueManager getManager()

Get the queue manager instance.

void setManager(QueueManager $manager)

Set the queue manager instance.

Details

void __construct(QueueManager $manager, FailedJobProviderInterface $failer = null, Dispatcher $events = null)

Create a new queue worker.

Parameters

QueueManager $manager
FailedJobProviderInterface $failer
Dispatcher $events

Return Value

void

array daemon(string $connectionName, string $queue = null, int $delay, int $memory = 128, int $sleep = 3, int $maxTries)

Listen to the given queue in a loop.

Parameters

string $connectionName
string $queue
int $delay
int $memory
int $sleep
int $maxTries

Return Value

array

protected void runNextJobForDaemon(string $connectionName, string $queue, int $delay, int $sleep, int $maxTries)

Run the next job for the daemon worker.

Parameters

string $connectionName
string $queue
int $delay
int $sleep
int $maxTries

Return Value

void

protected bool daemonShouldRun()

Determine if the daemon should process on this iteration.

Return Value

bool

array pop(string $connectionName, string $queue = null, int $delay, int $sleep = 3, int $maxTries)

Listen to the given queue.

Parameters

string $connectionName
string $queue
int $delay
int $sleep
int $maxTries

Return Value

array

protected Job|null getNextJob(Queue $connection, string $queue)

Get the next job from the queue connection.

Parameters

Queue $connection
string $queue

Return Value

Job|null

void process(string $connection, Job $job, int $maxTries, int $delay)

Process a given job from the queue.

Parameters

string $connection
Job $job
int $maxTries
int $delay

Return Value

void

Exceptions

Exception

protected array logFailedJob(string $connection, Job $job)

Log a failed job into storage.

Parameters

string $connection
Job $job

Return Value

array

protected void raiseFailedJobEvent(string $connection, Job $job)

Raise the failed queue job event.

Parameters

string $connection
Job $job

Return Value

void

bool memoryExceeded(int $memoryLimit)

Determine if the memory limit has been exceeded.

Parameters

int $memoryLimit

Return Value

bool

void stop()

Stop listening and bail out of the script.

Return Value

void

void sleep(int $seconds)

Sleep the script for a given number of seconds.

Parameters

int $seconds

Return Value

void

protected int|null getTimestampOfLastQueueRestart()

Get the last queue restart timestamp, or null.

Return Value

int|null

protected bool queueShouldRestart(int|null $lastRestart)

Determine if the queue worker should restart.

Parameters

int|null $lastRestart

Return Value

bool

void setDaemonExceptionHandler(Handler $handler)

Set the exception handler to use in Daemon mode.

Parameters

Handler $handler

Return Value

void

void setCache(Repository $cache)

Set the cache repository implementation.

Parameters

Repository $cache

Return Value

void

QueueManager getManager()

Get the queue manager instance.

Return Value

QueueManager

void setManager(QueueManager $manager)

Set the queue manager instance.

Parameters

QueueManager $manager

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/4.2/Illuminate/Queue/Worker.html