Listener

class Listener (View source)

Properties

protected string $commandPath The command working path.
protected string $environment The environment the workers should run under.
protected int $sleep The amount of seconds to wait before polling the queue.
protected int $maxTries The amount of times to try a job before logging it failed.
protected Closure|null $outputHandler The output handler callback.

Methods

void __construct(string $commandPath)

Create a new queue listener.

string phpBinary()

Get the PHP binary.

string artisanBinary()

Get the Artisan binary.

void listen(string $connection, string $queue, ListenerOptions $options)

Listen to the given queue connection.

Process makeProcess(string $connection, string $queue, ListenerOptions $options)

Create a new Symfony process for the worker.

array addEnvironment(array $command, ListenerOptions $options)

Add the environment option to the given command.

array createCommand(string $connection, string $queue, ListenerOptions $options)

Create the command with the listener options.

void runProcess(Process $process, int $memory)

Run the given process.

void handleWorkerOutput(int $type, string $line)

Handle output from the worker process.

bool memoryExceeded(int $memoryLimit)

Determine if the memory limit has been exceeded.

void stop()

Stop listening and bail out of the script.

void setOutputHandler(Closure $outputHandler)

Set the output handler callback.

Details

void __construct(string $commandPath)

Create a new queue listener.

Parameters

string $commandPath

Return Value

void

protected string phpBinary()

Get the PHP binary.

Return Value

string

protected string artisanBinary()

Get the Artisan binary.

Return Value

string

void listen(string $connection, string $queue, ListenerOptions $options)

Listen to the given queue connection.

Parameters

string $connection
string $queue
ListenerOptions $options

Return Value

void

Process makeProcess(string $connection, string $queue, ListenerOptions $options)

Create a new Symfony process for the worker.

Parameters

string $connection
string $queue
ListenerOptions $options

Return Value

Process

protected array addEnvironment(array $command, ListenerOptions $options)

Add the environment option to the given command.

Parameters

array $command
ListenerOptions $options

Return Value

array

protected array createCommand(string $connection, string $queue, ListenerOptions $options)

Create the command with the listener options.

Parameters

string $connection
string $queue
ListenerOptions $options

Return Value

array

void runProcess(Process $process, int $memory)

Run the given process.

Parameters

Process $process
int $memory

Return Value

void

protected void handleWorkerOutput(int $type, string $line)

Handle output from the worker process.

Parameters

int $type
string $line

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 setOutputHandler(Closure $outputHandler)

Set the output handler callback.

Parameters

Closure $outputHandler

Return Value

void

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