prolic/humus-amqp
Composer 安装命令:
composer require prolic/humus-amqp
包简介
PHP-AMQP library with RabbitMQ Extensions
README 文档
README
PHP 7.4 AMQP library
Documentation powered by Read the Docs.
Overview
PHP 7.4+ AMQP libray supporting multiple drivers and providing full-featured Consumer, Producer, and JSON-RPC Client / Server implementations.
The JSON-RPC part implements JSON-RPC 2.0 Specification.
Current supported drivers are: php-amqp and PhpAmqpLib.
php-amqp needs at least to be v1.9.3 php-amqplib needs at least to be v3
This library ships with psr/container factories that help you setting up everything.
Zend Framework and Symfony Framework Integration
Installation
You can install prolic/humus-amqp via composer by adding "prolic/humus-amqp": "^2.0" as requirement to your composer.json.
Usage
Exchange
$exchangeName = 'test-exchange';
$exchange = ExchangeFactory::$exchangeName($container);
$exchange->publish('test-message');
Queue
$queueName = 'test-queue';
$queue = QueueFactory::$queueName($container);
$message = $queue->get();
$queue->ack($message->getDeliveryTag());
Producer
$producerName = 'test-producer';
$producer = ProducerFactory::$producerName($container);
$producer->confirmSelect();
$producer->publish(['foo' => 'bar'], 'my-routing-key');
$producer->waitForConfirm();
JSON RPC Client
$clientName = 'my-client';
$client = JsonRpcClientFactory::$clientName($container);
$client->addRequest(new JsonRpcRequest('my-server', 'method', ['my' => 'params'], 'id-1'));
$client->addRequest(new JsonRpcRequest('my-server', 'method', ['my' => 'other_params'], 'id-2'));
$responseCollection = $client->getResponseCollection();
JSON RPC Server
$serverName = 'my-server';
$server = JsonRpcServerFactory::$serverName($container);
$server->consume();
Notes
Upgrade from 1.x to 1.4
Before: If auto_setup_fabric was enabled, the queue and exchange binding was done automatically. The exchanges would also get created. Anonymous queues required to have auto_setup_fabric set to true.
New: If auto_setup_fabric is enabled or the queue is anonymous (has no name), the queue gets created and binding is done, but no exchanges are created. If you want to enable creating of depending exchanges (including exchange binding), set the new argument auto_setup_exchanges to true.
This is a slight BC break, but the old behaviour was so problematic, that I had to make this change either way.
AMQP-Extension
- We recommend using php-amqp >=v1.9.3 or compiling it from master, if you encounter any problems with the amqp extension, check their issue tracker, first.
The ext-amqp driver is the most performant.
PhpAmqpLib
-
When using php-amqplib as driver, it's worth point out, that a StreamConnection (same goes for SSLConnection) does not have the possibility to timeout. If you want to let the consumer timeout, when no more messages are received, you should use the SocketConnection instead (assuming you don't need an SSL connection).
-
When using php-amqplib as driver and you're using the LazyConnection, you should not create the channel yourself, call instead
$channel = $connection->newChannel()
Support
- File issues at https://github.com/prolic/HumusAmqp/issues.
- Say hello in the HumusAmqp gitter chat.
Contribute
Please feel free to fork and extend existing or add new plugins and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.
License
Released under the MIT.
prolic/humus-amqp 适用场景与选型建议
prolic/humus-amqp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 210.44k 次下载、GitHub Stars 达 76, 最近一次更新时间为 2016 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「queue」 「rabbitmq」 「AMQP」 「messaging」 「humus」 「rabbit」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 prolic/humus-amqp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 prolic/humus-amqp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 prolic/humus-amqp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Queue
Work with RabbitMQ in Laravel.
Microservice RPC through message queues.
PHP AMQP Binding Library
The Listener component of the RabbitEvents library.
A Laravel package to monitor queue jobs.
统计信息
- 总下载量: 210.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 77
- 点击次数: 37
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-07