2017 © Pedro Peláez
 

library laravel-single-dispatch

Laravel Dispatcher extension for maintaining duplicate jobs

image

mbm-rafal/laravel-single-dispatch

Laravel Dispatcher extension for maintaining duplicate jobs

  • Monday, May 29, 2017
  • by mbm-rafal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 724 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 11 % Grown

The README.md

Single Dispatch

Extension for laravel dispatcher that do not allow to proceed same jobs on queues. Motivation for this feature is to not overuse resources while specific job is still waiting to be processed another one should not be queued., (*1)

Features

  • Allows to catch and ignore duplicated jobs

Requirements

Installed https://laravel.com/docs/5.4/queues, (*2)

Installation

Require the mbm-rafal/laravel-single-dispatch package in your composer.json and update your dependencies., (*3)

$ composer require mbm-rafal/laravel-single-dispatch
$ composer update

Publish migration files, (*4)

$ php artisan vendor:publish --provider="MBM\Bus\BusServiceProvider" --force

Run migrations, (*5)

$ php artisan migrate

Usage

To use this extension you have to update resource resolved by provided by Dispatcher::class to do so, simply switch BusServiceProvider in app/config.php, (*6)

// Illuminate\Bus\BusServiceProvider::class,
\MBM\Bus\BusServiceProvider::class,

You have to apply code to Queue events in AppServiceProvider, (*7)

# Manage processed jobs
Queue::after(function (JobProcessed $event) {
    app(\MBM\Bus\Dispatcher::class)->unregister($event->job);
});

Queue::failing(function (JobFailed $event) {
    app(\MBM\Bus\Dispatcher::class)->unregister($event->job);
});

If you want to allow job to be duplicated add interface to Job class definition, (*8)

use Illuminate\Contracts\Queue\ShouldQueue;
use \MBM\Bus\AllowDuplicates

class CustomJob implements ShouldQueue, AllowDuplicates
{
    // Code
}

License

Released under the MIT License, see LICENSE., (*9)

The Versions

29/05 2017

dev-master

9999999-dev

Laravel Dispatcher extension for maintaining duplicate jobs

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

laravel middleware dispatched

29/05 2017

dev-develop

dev-develop

Laravel Dispatcher extension for maintaining duplicate jobs

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

laravel middleware dispatched

28/05 2017

1.0.0

1.0.0.0

Laravel Dispatcher extension for maintaining duplicate jobs

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

laravel middleware dispatched