renatocason / magento2-module-mq
Magento 2 消息队列操作系统模块
1.1.4
2020-11-07 18:59 UTC
Requires
- php: ~7.1.0|~7.2.0|~7.3.0
- magento/framework: 100.1.*|101.0.*|102.0.*
Requires (Dev)
- php-coveralls/php-coveralls: ~2.1.0
- phpmd/phpmd: @stable
- phpunit/phpunit: ~6.5.13
- squizlabs/php_codesniffer: 3.3.1
Suggests
This package is auto-updated.
Last update: 2024-09-08 03:41:28 UTC
README
为 Magento 2 社区版提供的轻量级消息队列实现。
系统要求
本扩展支持以下版本的 Magento
- 社区版 (CE) 版本 2.1.x
- 社区版 (CE) 版本 2.2.x
- 社区版 (CE) 版本 2.3.x
安装
- 通过 Composer 需求此模块
$ composer require renatocason/magento2-module-mq
- 启用模块
$ bin/magento module:enable Rcason_Mq $ bin/magento setup:upgrade
- 安装您选择的任何消息队列后端扩展(见 消息队列后端 部分)
- 配置您的队列并实现您的消费者(见 实现 部分)
- 检查您的队列配置是否正确
$ bin/magento ce_mq:queues:list
- 运行您的消费者
$ bin/magento ce_mq:consumers:start product.updates
消息队列后端
本模块不包含任何消息队列后端实现。您需要选择并安装以下模块之一(或实现自己的模块),以便使消息队列工作
实现
一个简单的示例可以在这里找到这里。
- 在模块的 etc/m2_mq.xml 文件中配置队列
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Rcason_Mq:etc/ce_mq.xsd"> <ceQueue name="product.updates" broker="mysql" messageSchema="int" consumerInterface="Rcason\MqExample\Model\ExampleConsumer"/> </config>
- 在您需要的类中需要发布者
/** * @param \Rcason\Mq\Api\PublisherInterface $publisher */ public function __construct( \Rcason\Mq\Api\PublisherInterface $publisher ) { $this->publisher = $publisher; }
- 用它来排队消息
$this->publisher->publish('product.updates', $productId);
- 实现您的消费者
class ExampleConsumer implements \Rcason\Mq\Api\ConsumerInterface { /** * {@inheritdoc} */ public function process($productId) { // Your code here } }
作者、贡献者和维护者
作者
贡献
- grafikchaos
- jonathan-martz
- antoninobonumore
- 要查看贡献者完整列表,请访问GitHub 上的 Magento 2 消息队列模块
许可证
在 Open Software License 版本 3.0 下许可