honcho/craft-queue-bouncer
Composer 安装命令:
composer require honcho/craft-queue-bouncer
包简介
Prevent repeat jobs from being added to the queue
README 文档
README
Queue Bouncer for Craft CMS
A Craft CMS plugin that prevents duplicate jobs from piling up in the queue. If a matching job is already pending or running, Queue Bouncer skips the callback silently.
The Problem
Cron-triggered jobs can overlap. For example if a regular FeedMe import takes longer than its cron interval, a second job gets queued before the first finishes. Over time this creates a backlog that compounds the problem.
Queue Bouncer sits in front of your cron commands and acts as a gatekeeper - only running the callback function if there are no matching jobs in the queue.
Configuration
Copy config.php to config/queuebouncer.php and define your guarded jobs:
// config/queuebouncer.php return [ 'feed-me-import' => [ 'skipClasses' => [ \craft\feedme\queue\jobs\FeedImport::class, ], 'callback' => function () { $feed = FeedMe::getInstance()->getFeeds()->getFeedById(1); if ($feed) { Queue::push(new FeedImport(['feed' => $feed])); } }, ], ];
Each top-level key is an identifier you pass to the console command. A config entry supports these keys:
| Key | Description |
|---|---|
skipClasses |
Array of fully-qualified job class names. The callback is skipped if any are pending or running. Best for the simple case where the class name alone identifies the job. |
skipIf |
A callable returning true to skip the callback. Use this when you need finer control — for example to allow concurrent jobs of the same class but different feeds. Takes precedence over skipClasses when present. |
callback |
PHP callable invoked when the bouncer gives the green light. Omit it if you'd rather chain commands with && in cron. |
Advanced: skipIf
skipIf is useful when skipClasses is too broad. For example, if you run separate imports for multiple FeedMe feeds and want each one guarded independently:
'feed-me-import-17' => [ 'skipIf' => function () { // Only block if feed #17 is specifically already queued. return (new \yii\db\Query()) ->from(\craft\db\Table::QUEUE) ->where(['fail' => false]) ->andWhere(['like', 'job', 'FeedImport']) ->andWhere(['like', 'job', '"id";i:17']) ->exists(); }, 'callback' => function () { $feed = FeedMe::getInstance()->getFeeds()->getFeedById(17); if ($feed) { Queue::push(new FeedImport(['feed' => $feed])); } }, ], 'feed-me-import-42' => [ 'skipIf' => function () { return (new \yii\db\Query()) ->from(\craft\db\Table::QUEUE) ->where(['fail' => false]) ->andWhere(['like', 'job', 'FeedImport']) ->andWhere(['like', 'job', '"id";i:42']) ->exists(); }, 'callback' => function () { $feed = FeedMe::getInstance()->getFeeds()->getFeedById(42); if ($feed) { Queue::push(new FeedImport(['feed' => $feed])); } }, ],
Both keys can run concurrently — feed-me-import-17 won't block feed-me-import-42.
Usage
Replace your existing cron command with the Queue Bouncer equivalent:
# Before php craft feed-me/feeds/queue 1 # After php craft queue-bouncer/queue feed-me-import
Queue Bouncer will:
- Evaluate
skipIf(if configured) — if it returnstrue, exit cleanly. - Otherwise check
skipClasses— if any matching job is pending or running, exit cleanly. - If neither condition triggered, invoke the
callback.
License
MIT
honcho/craft-queue-bouncer 适用场景与选型建议
honcho/craft-queue-bouncer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 honcho/craft-queue-bouncer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 honcho/craft-queue-bouncer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2026-04-01
