Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Oct 15, 2023
1 parent c3207e2 commit 9e91551
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
40 changes: 20 additions & 20 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ Available options:

Allows you to publish a configuration class in the application namespace.

#### Example
##### Example

php spark queue:publish

### queue:job

Generates a new job file.

#### Arguments
##### Arguments

* `name` - The job class name.

#### Options
##### Options

* `--namespace` - Set root namespace. Default: "APP_NAMESPACE".
* `--suffix` - Append the component title to the class name (e.g. Email => EmailJob).
* `--force` - Force overwrite existing file.

#### Example
##### Example

php spark queue:job Email

Expand All @@ -49,11 +49,11 @@ It will generate the `Email` class in the `App\Jobs` namespace.

Allows you to consume jobs from a specific queue.

#### Arguments
##### Arguments

* `queueName` - Name of the queue we will work with.

#### Options
##### Options

* `-sleep` - Wait time between the next check for available job when the queue is empty. Default value: `10` (seconds).
* `-rest` - Rest time between the jobs in the queue. Default value: `0` (seconds)
Expand All @@ -64,7 +64,7 @@ Allows you to consume jobs from a specific queue.
* `-retry-after` - The number of seconds after which the job is to be restarted in case of failure. Overrides settings from the Job class. Disabled by default.
* `--stop-when-empty` - Stop when the queue is empty.

#### Example
##### Example

php spark queue:work emails -max-jobs 5

Expand All @@ -74,35 +74,35 @@ It will listen for 5 jobs from the `emails` queue and then stop.

Allows you to stop a specific queue in a safe way. It does this as soon as the job that is running in the queue is completed.

#### Arguments
##### Arguments

* `queueName` - Name of the queue we will work with.

#### Example
##### Example

php spark queue:stop emails

### queue:clear

Allows you to remove all jobs from a specific queue.

#### Arguments
##### Arguments

* `queueName` - Name of the queue we will work with.

#### Example
##### Example

php spark queue:clear emails

### queue:failed

Allows you to view all failed jobs. Also only from a specific queue

#### Options
##### Options

* `-queue` - Queue name.

#### Example
##### Example

php spark queue:failed -queue emails

Expand All @@ -112,15 +112,15 @@ It will list failed jobs from the `emails` queue.

Allows you to retry failed jobs back to the queue.

#### Arguments
##### Arguments

* `id` - ID of the failed job or "all" for all failed jobs.

#### Options
##### Options

* `-queue` - Queue name.

#### Example
##### Example

php spark queue:retry all -queue emails

Expand All @@ -130,24 +130,24 @@ It will retry all the failed jobs from the `emails` queue.

Allows you to delete the failed job by ID

#### Arguments
##### Arguments

* `id` - ID of the failed job.

#### Example
##### Example

php spark queue:forget 123

### queue:flush

Allows you to delete many failed jobs at once. Based on the failed date and queue.

#### Options
##### Options

* `-hours` - Number of hours.
* `-queue` - Queue name.

#### Example
##### Example

php spark queue:flush -hours 6

Expand Down
12 changes: 3 additions & 9 deletions docs/running_queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ Running a queue can be done in several ways. It all depends on what kind of envi

Since Supervisor is taking care of everything for us and will make out queue worker up and running, we can use this command:

```cli
php spark queue:work emails -wait 10
```
php spark queue:work emails -wait 10

This will cause command to check for the new jobs every 10 seconds if the queue is empty. But it will not quit. Waiting time is important since we don't want to overflow out database with the unnecessary queries.

### With CRON

Using queues with CRON is more challenging, but definitely doable. You can use command like this:

```cli
php spark queue:work emails -max-jobs 20 --stop-when-empty
```
php spark queue:work emails -max-jobs 20 --stop-when-empty

We can schedule CRON to execute our command every minute. This way, if there are no emails to handle, the command will quit immediately. And if there are many emails the batch of 20 will be handled every minute.

Expand All @@ -36,8 +32,6 @@ As mentioned above, sometimes we may want to have multiple instances of the same

If we decide to run the long process e.g. with the command:

```cli
php spark queue:work emails -wait 10
```
php spark queue:work emails -wait 10

We must remember to restart our command every time we add a new job or change the code in the existing job files. The reason is that the changes will not be visible before we restart the command.

0 comments on commit 9e91551

Please sign in to comment.