PHPackages                             fulfillment/laravel-triaged-queues - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. fulfillment/laravel-triaged-queues

ActiveLibrary[Queues &amp; Workers](/categories/queues)

fulfillment/laravel-triaged-queues
==================================

Extend Laravel 5 Queues to fallback to an arbitrary number of hosts in the event one is unreachable.

0.4.1(5y ago)516.7k1MITPHPPHP &gt;=5.5.9CI failing

Since Mar 11Pushed 5y ago3 watchersCompare

[ Source](https://github.com/Fulfillment-dot-com/laravel-triaged-queues)[ Packagist](https://packagist.org/packages/fulfillment/laravel-triaged-queues)[ RSS](/packages/fulfillment-laravel-triaged-queues/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (4)Versions (18)Used By (0)

Laravel 5.1 Triaged Queues
==========================

[](#laravel-51-triaged-queues)

*Extend Laravel 5.1 Queues to fallback to an arbitrary number of hosts in the event one is unreachable.*

This package extends Laravel 5.1 Queues by adding these features:

- Enable connection attempts to multiple hosts, sequentially, in the event the primary host is unreachable.
- If all hosts for a connection fail, enable falling back to the `sync` driver so that a job/command can be processed synchronously and therefore avoid data loss.
- (Beanstalkd Only) An extra `touch()` pheanstalk command is available on jobs and socket timeout can be specified via queue config.

Installation
------------

[](#installation)

Require this package

```
composer require "fulfillment/laravel-triaged-queues:0.1.*"
```

After adding the package, add the ServiceProvider to the providers array in `config/app.php`

```
Fulfillment\TriagedQueues\TriagedQueueServiceProvider::class,
```

and remove Laravel's `QueueServiceProvider` if present in `config/app.php`

```
'Illuminate\Queue\QueueSeverProvider'
```

Supported Drivers
-----------------

[](#supported-drivers)

Currently only the `beanstalkd` driver is supported. PRs for additional drivers are welcome.

Usage
-----

[](#usage)

A normal Queue Connection from `config/queue.php` looks like this:

```
'beanstalkd' => [
    'driver'         => 'beanstalkd',
    'host'           => env('BEANSTALK_HOST', 'localhost'),
    'queue'          => 'default',
    'ttr'            => 60,
    'socketTimeout'  => null
    ],
```

TriagedQueues offers three entries:

### hostN

[](#hostn)

Simply add an arbitrary number of host entries to the connection with this syntax

```
'host[N]' => '[host value]'
```

where **\[N\]** is the order you want that host to be attempted in. The primary host does not need a number.

EX:

```
'host'  => 'server.domain.com',
'host1' => 'server-fallback1.domain.com',
'host2' => 'server-fallback2.domain.com',
...
```

### fallbackToSync

[](#fallbacktosync)

If the entry `fallbackToSync` is set and `true` then TriagedQueues will use the `sync` driver in the event all hosts are unreachable.

EX:

```
'host'           => 'server.domain.com',
'host1'          => 'server-fallback1.domain.com',
'host2'          => 'server-fallback2.domain.com',
'fallbackToSync' => true
...
```

### attempts

[](#attempts)

Adding an `attempts` entry will make TriagedQueues try to establish a connection X number of tries before moving to the next host.

```
'attempts' => 2
```

### touch() (Beanstalkd Only)

[](#touch-beanstalkd-only)

A modified version of the `BeanstalkdJob` includes a `touch()` method which will send a `touch` command for the job to the beanstalkd queue. This resets the time-left (TTR minus running time) on the job so it isn't kicked back to the ready queue.

### socketTimeout (Beanstalkd Only)

[](#sockettimeout-beanstalkd-only)

If a job is long-running one must either increase TTR (time-to-run) for the job or `touch` it periodically to keep it reserved. However there is another factor that determines job behavior: [if the client disconnects while a job is reserved the job will be kicked back to the ready queue regardless of TTR](https://github.com/kr/beanstalkd/issues/11#issue-29600).

So for jobs that run longer than the default socket timeout (60 seconds, in ini settings) one must `touch` the job periodically, change this ini setting, or use the `socketTimeout` key-value in the configuration to specify timeout manually for `fsockopen`.

### Custom Queued Job

[](#custom-queued-job)

The default class that handles the "firing" of the command you have dispatched from the queued is `Illuminate\Queue\CallQueuedHandler`. However this default functionality does not allow a user to setup any logic for before the command is fired.

Using the `job` property in each Queue Connection you may specify an arbitrary `class@method` that will be called instead of `CallQueuedHandler` **when using automatic payload creation.** This means this only works if you use `Bus::dispatch()` or a similar method where the dispatcher creates the payload for you (and it is not a closure or raw payload).

Config looks like this:

```
'beanstalkd' => [
    'driver'         => 'beanstalkd',
    'host'           => env('BEANSTALK_HOST', 'localhost'),
    'queue'          => 'default',
    'ttr'            => 60,
    'socketTimeout'  => null,
    'job'            => 'app\MyCustomHandler@call'
    ],
```

I suggest you `extend` from `CallQueuedHandler` and override `call` to make things easier.

An example of using this could be to set authentication for the laravel worker instance before the job is handled.

```
class CallAuthenticatableQueuedHandler extends CallQueuedHandler
{
	public function call(Job $job, array $data)
	{
		$command = $this->setJobInstanceIfNecessary(
			$job, unserialize($data['command'])
		);

                // pipe an authentication middleware before the command is fired
		$this->dispatcher->pipeThrough([AuthenticateDispatchedJob::class])->dispatchNow($command, function ($handler) use ($job) {
			$this->setJobInstanceIfNecessary($job, $handler);
		});

		if (! $job->isDeletedOrReleased()) {
			$job->delete();
		}
	}
}
```

Contributing
------------

[](#contributing)

Contributing additional drivers is welcomed! The steps for creating a new driver are simple:

1. Create a new class in `Fulfillment\TriagedQueues\Queue\Connectors` that implements `Illuminate\Queue\Connectors\ConnectorInterface`
2. Implement `ConnectorInterface` (the `connect()` function), make sure your method attempts all listed hosts in the `$config` parameter.
3. If no host attempt works, throw `NoHostException`

Then make a PR and I will happily accept it :)

License
-------

[](#license)

This package is licensed under the [MIT license](https://github.com/Fulfillment-dot-com/laravel-triaged-queues/blob/master/LICENSE.txt).

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~229 days

Recently: every ~278 days

Total

9

Last Release

1935d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e034a2b4c63a810f72067441ec19dce7d9993a7fad0f1b27dd5734a4a2ad8070?d=identicon)[FoxxMD](/maintainers/FoxxMD)

![](https://www.gravatar.com/avatar/2263993374fa87b36ce7376802b73d5fd26d7a420ffc61bcf9049e7692526004?d=identicon)[Fulfillment.com](/maintainers/Fulfillment.com)

---

Top Contributors

[![FoxxMD](https://avatars.githubusercontent.com/u/4663766?v=4)](https://github.com/FoxxMD "FoxxMD (24 commits)")

### Embed Badge

![Health badge](/badges/fulfillment-laravel-triaged-queues/health.svg)

```
[![Health](https://phpackages.com/badges/fulfillment-laravel-triaged-queues/health.svg)](https://phpackages.com/packages/fulfillment-laravel-triaged-queues)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[mxl/laravel-queue-rate-limit

Simple Laravel queue rate limiting

93494.5k](/packages/mxl-laravel-queue-rate-limit)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3417.0k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
