PHPackages                             poolbang/queue - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. poolbang/queue

ActiveLibrary[Queues &amp; Workers](/categories/queues)

poolbang/queue
==============

queue for swoft

2.0.1(5y ago)7491Apache-2.0PHPPHP &gt;7.1CI failing

Since Aug 29Pushed 5y ago2 watchersCompare

[ Source](https://github.com/poolbang/queue)[ Packagist](https://packagist.org/packages/poolbang/queue)[ RSS](/packages/poolbang-queue/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (5)Versions (7)Used By (0)

Introduction
============

[](#introduction)

基于swoft2.0的redis延时队列 详细内容参考[有赞的延迟队列 ](https://tech.youzan.com/queuing_delay/)

### 欢迎使用queue 2.0

[](#欢迎使用queue-20)

queue V2.0版本的，配置更简单了，使用更简洁。 去除msg扩展，直接用json代替

### 安装 composer require poolbang/queue

[](#安装-composer-require-poolbangqueue)

添加config/queue.php文件，然后内容为：

```
reutrn [
        'contrast' => 10, //每次对比的元素数量， 默认: 10
        'interval' => 2, //空数据时等待时长， 默认: 1
        'log' => false, //是否写入日志， 默认: true
    ];

```

开启DelayQueue进程，在app/bean.php中的process添加下面内容：

```
        'process'  => [
             'queue' => bean(\Queue\Process\DelayQueueProcess::class),
        ],

```

##### job任务的类完成时执行的逻辑

[](#job任务的类完成时执行的逻辑)

```
namespace App\Models\Logic;

use Queue\JobHandler;
use Swoft\Bean\Annotation\Mapping\Bean;

/**
 * @Bean(scope=Bean::PROTOTYPE)
 * Class QueueLogic
 * @package App\Models\Logic
 */
class QueueLogic extends JobHandler
{

    protected function perform()
    {
        echo  'JobId: ' . $this->id . PHP_EOL;
        var_dump($this->args);
    }
}

```

#### 用法

[](#用法)

```
use Queue\DelayQueue;

/**
 * 添加
 *
 * @param  string $topic 一组相同类型Job的集合（队列）。
 * @param  string $jobName job任务的类名，是延迟队列里的基本单元。与具体的Topic关联在一起。
 * @param  integer $delay job任务延迟时间 传入相对于当前时间的延迟时间即可 例如延迟10分钟执行 传入 10*60
 * @param  integer $ttr job任务超时时间,保证job至少被消费一次,如果时间内未删除Job方法,则会再次投入ready队列中
 * @param  array $args 执行Job任务时传递的可选参数。
 * @param  string $jobId 任务id可传入或默认生成
 */
DelayQueue::enqueue('test',QueueLogic::class,5,10,['order_id'=>uniqid('queue_')]);
//获取
DelayQueue::get($jobId);
//删除
DelayQueue::remove($jobId);

```

#### \[future\]

[](#future)

用redis的发布订阅来处理消息

由于现在swoft的发布订阅出现问题，暂时不能用发布订阅来处理消息

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~160 days

Recently: every ~200 days

Total

6

Last Release

2016d ago

Major Versions

1.0.5 → 2.0.12020-11-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/4222451dfb512b82fe79b42fffe43606112c737d7d7743eb650d1c5252c013e8?d=identicon)[colinSu](/maintainers/colinSu)

---

Top Contributors

[![liojjv](https://avatars.githubusercontent.com/u/199267866?v=4)](https://github.com/liojjv "liojjv (9 commits)")[![webphplove](https://avatars.githubusercontent.com/u/14208245?v=4)](https://github.com/webphplove "webphplove (1 commits)")

---

Tags

phpdebugqueueswooleswoft

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/poolbang-queue/health.svg)

```
[![Health](https://phpackages.com/badges/poolbang-queue/health.svg)](https://phpackages.com/packages/poolbang-queue)
```

###  Alternatives

[swoft/swoft

Modern High performance AOP and Coroutine PHP Framework

5.5k34.5k](/packages/swoft-swoft)[swoft/devtool

Devtool for swoft framework

26154.1k5](/packages/swoft-devtool)[microsoft/azure-storage-queue

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Queue APIs.

142.6M17](/packages/microsoft-azure-storage-queue)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
