承接 sanmark/laravel-queue-fallback 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sanmark/laravel-queue-fallback

最新稳定版本:v1.0.0

Composer 安装命令:

composer require sanmark/laravel-queue-fallback

包简介

README 文档

README

Laravel Queue Fallback is a package designed to provide seamless fallback mechanisms for queue services in Laravel applications. It ensures that your queued jobs are processed even if the primary queue service encounters issues, thereby enhancing the reliability and resilience of your application's background processing tasks.

Features

  • Automatic fallback to secondary queue service in case of primary service failures.
  • Configuration options for customizing fallback behavior.
  • Compatibility with Laravel's native queue configuration and services.

Installation

You can install the package via Composer. Run the following command in your terminal:

composer require sanmark/laravel-queue-fallback

Add fallback queue connection (add below env file into your project .env file)

FAILBACK_QUEUE_CONNECTION = "database"

Usage

To use this package, you need to:

Use the Sanmark\QueueFallback\ShouldFallback trait in your job files.

namespace App\Jobs;

use Sanmark\QueueFallback\ShouldFallback;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class ExampleJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, ShouldFallback;

    public function handle()
    {
        // Job logic here
    }
}

Use dispatchWithFallback instead of dispatch when dispatching jobs.

use App\Jobs\ExampleJob;


ExampleJob::dispatchWithFallback($parameter);

This ensures that if the primary queue service fails, the job will be automatically dispatched to the secondary queue service specified in the configuration.

Configuration

After installing the package, you can configure it by publishing the configuration file. Run the following artisan command:

php artisan vendor:publish --provider="Sanmark\\QueueFallback\\QueueFallbackServiceProvider"

This command will publish a configuration file named queue-fallback.php in your Laravel application's config directory. You can customize the fallback behavior and specify your secondary queue service in this file.

Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on GitHub.

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-22