PHPackages                             php-mq/protocol - 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. php-mq/protocol

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

php-mq/protocol
===============

The PHPMQ message protocol

1126[1 issues](https://github.com/php-mq/protocol/issues)PHP

Since Jan 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/php-mq/protocol)[ Packagist](https://packagist.org/packages/php-mq/protocol)[ RSS](/packages/php-mq-protocol/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c7b0ad08ffdcb12faa1ee6c402455131486e064b2df4387aa96581d00abe0020/68747470733a2f2f7472617669732d63692e6f72672f7068702d6d712f70726f746f636f6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-mq/protocol)[![Latest Stable Version](https://camo.githubusercontent.com/9d258e983b73b951fbb9d97589568eb362e7ade8547f9df18b27e72093244f54/68747470733a2f2f706f7365722e707567782e6f72672f7068702d6d712f70726f746f636f6c2f762f737461626c65)](https://packagist.org/packages/php-mq/protocol)[![Total Downloads](https://camo.githubusercontent.com/7393a5d5e3b53d8174aa7b119e1b11b192e3018add8f445b4d75417cc57026b1/68747470733a2f2f706f7365722e707567782e6f72672f7068702d6d712f70726f746f636f6c2f646f776e6c6f616473)](https://packagist.org/packages/php-mq/protocol)[![Coverage Status](https://camo.githubusercontent.com/b846a770162fbc0e3b4846b50ae183152d8e21f214ce781022cd6459c8cf8fba/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068702d6d712f70726f746f636f6c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/php-mq/protocol?branch=master)

Protocol
========

[](#protocol)

Description
-----------

[](#description)

The PHPMQ message protocol

Installation
------------

[](#installation)

```
composer require php-mq/protocol
```

Usage
-----

[](#usage)

---

Message headers
---------------

[](#message-headers)

Each message sent from a client to the endpoint must have a leading header line which defines:

- A flag that identifies the line as message header
- A number that identifies the version of the message protocol
- The type of the message (see [message types](#message-types)) (3 bytes)
- The number of the following packages (see [packet types](#packet-types))

Example:

```
H0100102

means:

PACKET-ID | VERSION | MSG-TYPE | PACKAGE COUNT
        H |      01 |      001 |            02

```

So a header always has a length of 8 byte.

Message types
-------------

[](#message-types)

- `001` - Client sends a message (client to server)
- `002` - Client wants to consume messages (consume request)
- `003` - Server dispatches a message (server to client)
- `004` - Client acknowledges a message (acknowledgement)
- `005` - Client wants to re-queue a message (pop from queue, append to queue)
- `006` - Client sends a dead letter for a message (remove message from queue)

Packet headers
--------------

[](#packet-headers)

Each data package in a message is preceded by a package header with defines:

- A flag that identifies the line as package header
- A number that identifies the package type
- The length of the following package content

Example:

```
P01000000000000000000000000000000256

means:

PACKET-ID | PKG-TYPE | CONTENT-LENGTH (as int)
        P |       01 |                     256

```

So a package header always has a length of 32 byte.

**Please note:** The content length has a length of 32 bytes and is filled up with zeros.

Packet types
------------

[](#packet-types)

### All

[](#all)

PKG-TypeMeaning01Queue name02Message content03Message ID04Count of message for consumption05Time to live of message (TTL)---

### For messages from client to endpoint

[](#for-messages-from-client-to-endpoint)

- `01` - Queue name
- `02` - Message content
- `05` - Message TTL

### For messages from endpoint to client

[](#for-messages-from-endpoint-to-client)

- `01` - Queue name
- `02` - Message content
- `03` - Message ID
- `05` - Message TTL

### For Consumption

[](#for-consumption)

- `01` - Queue name
- `04` - Count of messages the client wants to consume from the queue

### For message acknowledgment

[](#for-message-acknowledgment)

- `01` - Queue name
- `03` - Message ID

### For message re-queue

[](#for-message-re-queue)

- `01` - Queue name
- `03` - Message ID
- `05` - Message TTL

### For dead letter

[](#for-dead-letter)

- `01` - Queue name
- `03` - Message ID

---

Full message examples
---------------------

[](#full-message-examples)

### Send a message

[](#send-a-message)

Client sends a new message with content "Hello World" for queue "Foo" to server with a TTL of 3600 seconds.

```
H0100103
P0100000000000000000000000000003
Foo
P0200000000000000000000000000011
Hello World
P0500000000000000000000000000004
3600

```

### Consume messages

[](#consume-messages)

Client wants to consume 5 messages from queue "Foo".

```
H0100202
P0100000000000000000000000000003
Foo
P0400000000000000000000000000001
5

```

### Dispatch a message

[](#dispatch-a-message)

Server sends the message above to the client 300 seconds later.

```
H0100304
P0100000000000000000000000000003
Foo
P0200000000000000000000000000011
Hello World
P0300000000000000000000000000032
d7e7f68761d34838494b233148b5486c
P0500000000000000000000000000004
3300

```

**Note:** TTL was reduced to 3300 seconds.

### Acknowledge a message

[](#acknowledge-a-message)

Client acknowledges the consumed message with ID `d7e7f68761d34838494b233148b5486c`.

```
H0100402
P0100000000000000000000000000003
Foo
P0300000000000000000000000000032
d7e7f68761d34838494b233148b5486c

```

### Re-queue a message

[](#re-queue-a-message)

Client wants the message to be re-queued at the end of the queue, with a new TTL of 3600 seconds.

```
H0100503
P0100000000000000000000000000003
Foo
P0300000000000000000000000000032
d7e7f68761d34838494b233148b5486c
P0500000000000000000000000000004
3600

```

### Send a dead letter

[](#send-a-dead-letter)

Client wants the message to be removed from queue, regardless its TTL

```
H0100602
P0100000000000000000000000000003
Foo
P0300000000000000000000000000032
d7e7f68761d34838494b233148b5486c

```

---

Contributing
------------

[](#contributing)

Contributions are welcome and will be fully credited. Please see the [contribution guide](.github/CONTRIBUTING.md) for details.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1557839?v=4)[Holger Woltersdorf](/maintainers/hollodotme)[@hollodotme](https://github.com/hollodotme)

---

Top Contributors

[![hollodotme](https://avatars.githubusercontent.com/u/1557839?v=4)](https://github.com/hollodotme "hollodotme (19 commits)")

---

Tags

message-queueprotocol

### Embed Badge

![Health badge](/badges/php-mq-protocol/health.svg)

```
[![Health](https://phpackages.com/badges/php-mq-protocol/health.svg)](https://phpackages.com/packages/php-mq-protocol)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[amphp/parser

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13451.1M18](/packages/amphp-serialization)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[deliciousbrains/wp-background-processing

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.

1.1k409.8k6](/packages/deliciousbrains-wp-background-processing)[react/async

Async utilities and fibers for ReactPHP

2238.8M171](/packages/react-async)

PHPackages © 2026

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