mattyeend/queue-monitor 问题修复 & 功能扩展

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

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

mattyeend/queue-monitor

Composer 安装命令:

composer require mattyeend/queue-monitor

包简介

A Laravel package to monitor queue logs.

README 文档

README

A Laravel package for real-time monitoring of queues with stats on processing time, failed jobs, and retry status.

Features

  • Real-time queue monitoring.
  • Detailed stats on processing time and retries.
  • Notifications for failed jobs.

Installation

  1. Require the package via Composer
    composer require MattYeend/queue-monitor
  2. Publish the configuration, views, and migrations:
    php artisan vendor:publish --provider="MattYeend\QueueMonitoring\QueueMonitoringServiceProvider"
  3. Run the migrations to create the necessary database table:
    php artisan migrate
  4. Access the dashboard at /queue-monitor (or a custom route if configured)

Usage

  1. Queue Monitoring Dashboard Once installed, the package provides a monitoring dashboard accessible at /queue-monitor (or a custom route specified in config/queue-monitor.php). The dashboard displays:
  • The list of queues being monitored.
  • The number of jobs processed.
  • The number of failed jobs.
  • The average processing time for each queue.
  1. Automatically Updating Queue Statistics To update queue statistics after job processing:
  • Inject the QueueMonitorService into your job classes or relevant services.
  • Use the updateQueueStatus method to log the queue name, processing time, and failure status. Example Integration in a Job:
use MattYeend\QueueMonitoring\Services\QueueMonitorService;

class ExampleJob implements ShouldQueue
{
    public function handle(QueueMonitorService $service)
    {
        $queueName = 'example-queue';
        $startTime = microtime(true);

        try {
            // Performs job processing
        } catch (\Exception $e) {
            $service->updateQueueStatus($queueName, 0, true); // Log a failed job
            throw $e;
        }

        $endTime = microtime(true);
        $processingTime = ($endTime - $StartTime) * 1000; // Convert to milliseconds
        $service->updateQueueStatus($queueName, $processingTime, false); // Log a successful job
    }
}
  1. Customising the Dashboard You can customise the dashboard view by modifying the published Blade file resources/views/vendor/queue-monitor/dashboard.blade.php
  2. Custom Route The change the route for the dashboard, edit the dashboard_route value in the configuration file 'dashboard_route' => '/admin/queue-status'
  3. Notifications for Failed Jobs To enable email notifications for failed jobs:
  • Add the following to your .env file: QUEUE_MONITOR_NOTIFICATION_EMAIL=devops@yourcompany.com
  • The configured email address will receive alerts whenever a job fails in a monitored queue.

Configuration

.env File

To configure email notifications for failed jobs, add the following line to your .env file:

QUEUE_MONITOR_NOTIFICATION_EMAIL=devops@yourcompany.com

This will be used to send notifications for failed jobs. If not set, it will default to admin@example.com.

Custom Dashboard Route

To change the default URL route, modify the config/queue-monitor.php file. For example

'dashboard_route' => '/admin/queue-status',

Tests

Setting Up the Test Environment

  1. Install Dependencies
composer install
  1. Configure your environment Ensure your .env file is set up for testing. By default, the TestCase class configures an in-memory SQLite database for testing, so no additional setup is required.

Running the Test

  1. Run all tests
php artisan test

or:

./vendor/bin/phpunit

License

This package is licensed under the MIT License.

Contributing

Feel free to fork the repository and submit pull requests for improvements or new features!

mattyeend/queue-monitor 适用场景与选型建议

mattyeend/queue-monitor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 01 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「package」 「monitoring」 「monitor」 「laravel」 「queue-monitor」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mattyeend/queue-monitor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mattyeend/queue-monitor 我们能提供哪些服务?
定制开发 / 二次开发

基于 mattyeend/queue-monitor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-14