承接 jaapieaapie1/rabbitmq-ext 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jaapieaapie1/rabbitmq-ext

最新稳定版本:1.0.0

Composer 安装命令:

pie install jaapieaapie1/rabbitmq-ext

包简介

A PHP extension for RabbitMQ, written in Rust using ext-php-rs and lapin

README 文档

README

A PHP extension for consuming RabbitMQ queues, written in Rust using ext-php-rs and lapin.

Why

The benefit of this approach compared to implementing an RabbitMQ client in PHP is that we can multithread and thus keep sending heartbeats even though the php process is busy doing other things.
This makes it so the connection stays open even when you are processing a job that takes 30 minutes.

Support

This package officially supports and is tested against PHP 8.1 - 8.5.

Installing

To install the extension use PHP's official extension installer PIE. The extension is published on packagist.
For most architecture php combinations prebuilt binaries are available (only PIE version > 1.4 supports downloading prebuilt binaries)
If your specific setup is not prebuilt Rust's buildtools are required to build this library.

pie install jaapieaapie1/rabbitmq-ext

For IDE's and PHPStan there are stubs available as a composer package.

composer require --dev jaapieaapie1/rabbitmq-ext-stubs

Usage

Consuming messages

use RabbitMQ\Connection;

$connection = new Connection('amqp://guest:guest@localhost:5672');
$consumer = $connection->consume('my-queue', prefetchCount: 50);

$consumer->each(function ($message) {
    echo $message->getBody() . PHP_EOL;

    $message->ack();

    return true; // return false to stop consuming
});

$connection->close();

Consuming with a timeout

$consumer = $connection->consume('my-queue');

while ($message = $consumer->next(timeoutMs: 5000)) {
    echo $message->getRoutingKey() . ': ' . $message->getBody() . PHP_EOL;
    $message->ack();
}

// null returned — timed out or consumer was cancelled
$connection->close();

Publishing messages

$connection = new Connection('amqp://guest:guest@localhost:5672');

// Publish and wait for broker confirmation
$connection->publish('my-exchange', 'routing.key', '{"event":"order.created"}', [
    'x-request-id' => 'abc-123',
]);

// Fire-and-forget (confirmed before connection closes)
$connection->publishAsync('my-exchange', 'routing.key', 'payload');

$connection->close();

Handling failures

$consumer = $connection->consume('my-queue');

$consumer->each(function ($message) {
    try {
        processMessage($message->getBody());
        $message->ack();
    } catch (\Throwable $e) {
        $message->nack(requeue: false); // dead-letter the message
    }

    return true;
});

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Rust

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固