renatocason / magento2-module-mq
Magento 2 Message Queue OS Module
Installs: 14 939
Dependents: 3
Suggesters: 0
Security: 0
Stars: 36
Watchers: 9
Forks: 18
Open Issues: 5
Type:magento2-module
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-11-08 04:14:44 UTC
README
Lightweight implementation of message queue for Magento 2 Community Edition.
System requirements
This extension supports the following versions of Magento:
- Community Edition (CE) versions 2.1.x
- Community Edition (CE) versions 2.2.x
- Community Edition (CE) versions 2.3.x
Installation
- Require the module via Composer
$ composer require renatocason/magento2-module-mq
- Enable the module
$ bin/magento module:enable Rcason_Mq $ bin/magento setup:upgrade
- Install a message queue backend extension of your choice (see Message queue backends section)
- Configure your queue(s) and implement your consumer(s) (see Implementation section)
- Check the correct configuration of your queue(s)
$ bin/magento ce_mq:queues:list
- Run your consumer(s)
$ bin/magento ce_mq:consumers:start product.updates
Message queue backends
This module does not include any message queue backend implementation. You will have to chose and install one of the following modules (or implement your own) in order to get your message queues working:
- MqMysql - Stores messages in the database
- MqAmqp - Integrates any AMQP queue manager (i.e. RabbitMQ)
- Amazon SQS - Integrates Amazon SQS as a queue manager (work in progress)
Implementation
A simple example can be found here.
- Configure queue(s) in your module's etc/m2_mq.xml file
<?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>
- Require the publisher in the classes you need it
/** * @param \Rcason\Mq\Api\PublisherInterface $publisher */ public function __construct( \Rcason\Mq\Api\PublisherInterface $publisher ) { $this->publisher = $publisher; }
- Use it to queue messages
$this->publisher->publish('product.updates', $productId);
- Implement your consumer(s)
class ExampleConsumer implements \Rcason\Mq\Api\ConsumerInterface { /** * {@inheritdoc} */ public function process($productId) { // Your code here } }
Authors, contributors and maintainers
Author:
Contributions:
- grafikchaos
- jonathan-martz
- antoninobonumore
- For a full list of contributors visit Magento 2 Message Queue Module on GitHub
License
Licensed under the Open Software License version 3.0