PHPackages                             easyswoole/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. [Caching](/categories/caching)
4. /
5. easyswoole/queue

ActiveLibrary[Caching](/categories/caching)

easyswoole/queue
================

A simple Queue implementation integrated into easySwoole

4.8.12(2y ago)1233.3k↓50%10[3 issues](https://github.com/easy-swoole/queue/issues)8Apache-2.0PHPPHP &gt;=8.0

Since Dec 23Pushed 2y agoCompare

[ Source](https://github.com/easy-swoole/queue)[ Packagist](https://packagist.org/packages/easyswoole/queue)[ RSS](/packages/easyswoole-queue/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (31)Used By (8)

Queue
=====

[](#queue)

安装
--

[](#安装)

```
composer require easyswoole/queue
```

### 队列驱动

[](#队列驱动)

任何队列驱动都必须实现`EasySwoole\Queue\QueueDriverInterface`这个接口定义。且实现的对象一定是必须可被克隆(可以看Queue中的Producer方法即知道为何)。 队列在被加载到对应topic的Producer和Consumer时，都会被分别执行一次init()方法。

### 创建队列

[](#创建队列)

```
use EasySwoole\Queue\Driver\RedisQueue;
use EasySwoole\Queue\Queue;
use EasySwoole\Redis\Config;

$config = new Config([
    'host'=>"",
    'port'=>"",
    'auth'=>""
]);

$driver = new RedisQueue($config);
$queue = new Queue($driver);
```

### 普通生产

[](#普通生产)

```
$job = new Job();
$job->setJobData("this is my job data time time ".date('Ymd h:i:s'));
$queue->producer("topic")->push($job);

```

### 普通消费

[](#普通消费)

```
$job = $queue->consumer("topic")->pop();
//或者是自定义进程中
$queue->consumer("topicName")->listen(function (Job $job){
    var_dump($job);
});
```

CLI 单独使用
--------

[](#cli-单独使用)

```
use EasySwoole\Queue\Driver\RedisQueue;
use EasySwoole\Queue\Job;
use EasySwoole\Queue\Queue;
use EasySwoole\Redis\Config;
use Swoole\Coroutine;
use Swoole\Coroutine\Scheduler;

require "vendor/autoload.php";

$sc = new Scheduler();
$sc->add(function (){
    $config = new Config([
        'host'=>"",
        'port'=>"",
        'auth'=>""
    ]);

    $driver = new RedisQueue($config);
    $queue = new Queue($driver);

    Coroutine::create(function ()use($queue){
        while (1){
            Coroutine::sleep(3);
            $job = new Job();
            $job->setJobData("job test create at ".time());
            try {
                $queue->producer("test")->push($job);
            }catch (\Throwable $throwable){

            }
        }
    });

    Coroutine::create(function ()use($queue){
        while (1){
            Coroutine::sleep(5);
            $job = new Job();
            $job->setJobData("job another create at ".time());
            try {
                $queue->producer("another")->push($job);
            }catch (\Throwable $throwable){

            }
        }
    });

    Coroutine::create(function ()use($queue){
        $queue->consumer("test")->listen(function (Job $job){
            var_dump($job->getJobData() ." hande in test");
        },[],function (){

        });
    });

    Coroutine::create(function ()use($queue){
        $queue->consumer("another")->listen(function (Job $job){
            var_dump($job->getJobData() ." hande in another");
        },[],function (){

        });
    });

});

$sc->start();
```

延迟任务
----

[](#延迟任务)

```
$job = new Job();
$job->setJobData("this is my job data time time ".date('Ymd h:i:s'));
$job->setDelayTime(5);//设置延后时间
$queue->producer("topic")->push($job);

```

可信任务
----

[](#可信任务)

```
$job = new Job();
$job->setJobData("this is my job data time time ".date('Ymd h:i:s'));
$job->setRetryTimes(3);//任务如果没有确认，则会执行三次
$job->setWaitConfirmTime(5);//如果5秒内没确认任务，会重新回到队列。默认为3秒
$queue->producer("topic")->push($job);//投递任务
//确认一个任务
$queue->consumer("topic")->confirm($job);

```

消费者控制
-----

[](#消费者控制)

当队列未`pop`到`job`时：

```
/** @var \EasySwoole\Queue\Queue $queue */
$queue->consumer("topic")->setOnBreak(function(\EasySwoole\Queue\Consumer $consumer) {
     // todo
 })->listen(function (\EasySwoole\Queue\Job $job){ });
```

设置`breakTime`：

```
/** @var \EasySwoole\Queue\Queue $queue */
$queue->consumer("topic")->setBreakTime(0.1);
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 70.8% 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 ~71 days

Recently: every ~32 days

Total

30

Last Release

1007d ago

Major Versions

1.0.1 → 2.0.02019-08-08

2.1.x-dev → 3.0.02021-02-22

3.x-dev → 4.0.12023-02-16

PHP version history (2 changes)1.0.0PHP &gt;=5.6.0

4.0.8PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/45c234d5f129ea570e630425636299127647534f0c2cbb073555e2c45d403d6f?d=identicon)[kiss291323003](/maintainers/kiss291323003)

---

Top Contributors

[![kiss291323003](https://avatars.githubusercontent.com/u/24490609?v=4)](https://github.com/kiss291323003 "kiss291323003 (46 commits)")[![Player626](https://avatars.githubusercontent.com/u/44792981?v=4)](https://github.com/Player626 "Player626 (6 commits)")[![huizhang001](https://avatars.githubusercontent.com/u/26496638?v=4)](https://github.com/huizhang001 "huizhang001 (5 commits)")[![evalor](https://avatars.githubusercontent.com/u/26944445?v=4)](https://github.com/evalor "evalor (4 commits)")[![tioncico](https://avatars.githubusercontent.com/u/31308307?v=4)](https://github.com/tioncico "tioncico (3 commits)")[![codepass0](https://avatars.githubusercontent.com/u/52648792?v=4)](https://github.com/codepass0 "codepass0 (1 commits)")

---

Tags

redisqueuebeanstalkdeasyswoole

### Embed Badge

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

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

###  Alternatives

[mjphaynes/php-resque

Redis backed library for creating background jobs and processing them later.

228199.3k2](/packages/mjphaynes-php-resque)[enqueue/redis

Message Queue Redis Transport

405.5M25](/packages/enqueue-redis)[javibravo/simpleue

Php package to manage queue tasks in a simple way

130332.1k1](/packages/javibravo-simpleue)[resquebundle/resque

A Symfony 4 bundle to manage Resque job queues

51137.1k1](/packages/resquebundle-resque)[spinx/sidekiq-job-php

Push and schedule jobs to Sidekiq from PHP

37219.6k](/packages/spinx-sidekiq-job-php)[pdffiller/qless-php

PHP Bindings for qless

29113.2k1](/packages/pdffiller-qless-php)

PHPackages © 2026

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