mbm-rafal/laravel-single-dispatch 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mbm-rafal/laravel-single-dispatch

Composer 安装命令:

composer require mbm-rafal/laravel-single-dispatch

包简介

Laravel Dispatcher extension for maintaining duplicate jobs

README 文档

README

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.

Features

  • Allows to catch and ignore duplicated jobs

Requirements

Installed https://laravel.com/docs/5.4/queues

Installation

Require the mbm-rafal/laravel-single-dispatch package in your composer.json and update your dependencies.

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

Publish migration files

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

Run migrations

$ 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

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

You have to apply code to Queue events in AppServiceProvider

# 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

use Illuminate\Contracts\Queue\ShouldQueue;
use \MBM\Bus\AllowDuplicates
 
class CustomJob implements ShouldQueue, AllowDuplicates
{
    // Code
}

License

Released under the MIT License, see LICENSE.

统计信息

  • 总下载量: 6.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固