PHPackages                             lishelun/kdt-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. lishelun/kdt-queue

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

lishelun/kdt-queue
==================

v1.0.1(2y ago)03PHP

Since Dec 25Pushed 2y agoCompare

[ Source](https://github.com/lishelun/php-nsq-client)[ Packagist](https://packagist.org/packages/lishelun/kdt-queue)[ RSS](/packages/lishelun-kdt-queue/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

NSQ PHP CLIENT
==============

[](#nsq-php-client)

Reference
---------

[](#reference)

namespace: `Kdt\Iron\Queue\Queue`

### `class Queue`

[](#class-queue)

#### `function push(string $topic, mixed $message) : bool`

[](#function-pushstring-topic-mixed-message--bool)

发布单个消息

`$message` 为 `Kdt\Iron\Queue\Message` 对象 或简单类型，如 `string`, `array`，使用 `Message` 对象时可以使用一些高级属性

#### `function bulkPush(string $topic, array $messages) : bool`

[](#function-bulkpushstring-topic-array-messages--bool)

批量发布消息

`$messages` 是一个一维消息数组

#### `function lastPushError() : string`

[](#function-lastpusherror--string)

获取上次发布的错误信息

#### `function pop(mixed $topic, callable $callback, array $options) : mixed`

[](#function-popmixed-topic-callable-callback-array-options--mixed)

订阅消息。正常退出时会返回 false; 异常退出时返回 string，内容为异常信息

`$topic` 为 `string` 时，使用默认的 channel 名 `default`；指定 channel 时需要传入一个包含 2 个元素的一维数组 `[$topic_name, $channel]`

`$callback` 为 `function($message)`，有新消息时会触发回调，参数为 `Message` 对象。

`$options` 是一个关系数组，有以下选项：

- auto\_delete : bool

    是否启用自动 ACK，默认 false
- keep\_seconds : int

    daemon运行时间，单位秒，默认 900
- max\_retry : int

    异常时的重试次数，默认 3
- retry\_delay : int

    重试的间隔时间，单位秒，默认 5
- sub\_ordered : bool

    是否启用顺序消费，默认 false
- sub\_partition : int

    订阅指定的分区（顺序消费时），默认订阅所有分区或 nsq 节点

#### `function exitPop()`

[](#function-exitpop)

退出 pop 后不会再接收新消息

#### `function delete(string $messageId) : bool`

[](#function-deletestring-messageid--bool)

删除消息（标记 ACK）

`$messageId` 通过 `Message` 对象的 `getId()` 方法获取

#### `function later(int $seconds)`

[](#function-laterint-seconds)

消息延迟

单位秒，默认情况下最大 3600； 实现机制为抛出一个特定的异常对象 (nsqphp\\Exception\\RequeueMessageException) 给 SDK，注意外层尽量不要自己包装 try catch

#### `function retry()`

[](#function-retry)

消息重试

#### `function close()`

[](#function-close)

主动关闭网络链接，只能在 pop 中使用

### `class Message`

[](#class-message)

#### `function getId() : string`

[](#function-getid--string)

消息 ID

#### `function getTimestamp() : int`

[](#function-gettimestamp--int)

消息产生时间戳

#### `function getAttempts() : int`

[](#function-getattempts--int)

消息已经重试的次数，包含客户端主动重试和其他未知原因导致的服务端自动重试

### `function getPayload() : mixed`

[](#function-getpayload--mixed)

消息内容

#### `function getTraceID() : int`

[](#function-gettraceid--int)

消息追踪 ID，由生产端传入

#### `function getShardingProof() : int`

[](#function-getshardingproof--int)

分区依据

#### `function setTraceID($id) : self`

[](#function-settraceidid--self)

设置消息追踪 ID，会传递到消费端

#### `function setShardingProof(int $sample) : self`

[](#function-setshardingproofint-sample--self)

设置分区依据，会根据取模结果来决定目标分区

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 72.5% 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 ~2177 days

Total

2

Last Release

934d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13258880?v=4)[Lee](/maintainers/lishelun)[@lishelun](https://github.com/lishelun)

---

Top Contributors

[![moolex](https://avatars.githubusercontent.com/u/1132321?v=4)](https://github.com/moolex "moolex (50 commits)")[![xiezhenye](https://avatars.githubusercontent.com/u/2225688?v=4)](https://github.com/xiezhenye "xiezhenye (15 commits)")[![goghcrow](https://avatars.githubusercontent.com/u/6487418?v=4)](https://github.com/goghcrow "goghcrow (3 commits)")[![lishelun](https://avatars.githubusercontent.com/u/13258880?v=4)](https://github.com/lishelun "lishelun (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.6M31](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6046.3M541](/packages/illuminate-bus)[uecode/qpush-bundle

Asynchronous processing for Symfony using Push Queues

1672.5M2](/packages/uecode-qpush-bundle)[kohkimakimoto/workerphp

A PHP micro job scheduler framework like cron.

1113.7k](/packages/kohkimakimoto-workerphp)[belvg/module-sqs

N/A

1544.6k](/packages/belvg-module-sqs)[mayconbordin/l5-stomp-queue

Stomp Queue Driver for Laravel 5

121.1k](/packages/mayconbordin-l5-stomp-queue)

PHPackages © 2026

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