Magento 2 is distinguished by the number of features Magento 1 feels lack. One of the examples is Queues which allow executing time and resource-consuming tasks such as product import, stocks management, API interfaces, indexation asynchronously. Magento 2 box version provides interfaces for accessing AMQP and MySQL queues. As for MySQL, the queues are based on the cron job tasks. This solution performs great for middle-size websites. But there’s an issue concerning high-load projects, as cron job can not manage all scheduled tasks during one iteration. In such a way, the queue can become a potential source of serious bugs.
Our investigations showed that RabbitMQ can be considered as the way out. RabbitMQ service can be connected to Magento 2 by creating a separate module with the queue.xml file, that defines the Queue connection attribute type=”amqp” in it. This workflow gives us access to all Queue functions and allows us to expand default functionality with additional features.
The only real problem you can face while using RabbitMQ is that not every hosting company is eager to install RabbitMQ service by your request. You can setup everything yourself, but it’s not convenient and requires much effort and administrative knowledge.
Let’s suppose Amazon doesn’t provide queues service on RabbitMQ, but it has its own queues service – SQS. The service is simpler than RabbitMQ and doesn’t have additional options. But in most cases, all these extra options are not necessary. As a rule, you need the queue to send messages. SQS has obvious benefit if compared with RabbitMQ. In Amazon ecosystem SQS is available everywhere and doesn’t need to be installed separately. After weighing all the pros and cons, we decided to create a separate module which allows using Amazon SQS service with Magento 2 Queues with ease. You can download the module via packagist.
Now let’s consider how to install the module. In order to connect the module, in the file app/etc/env.php in the section “queues”, you need to enter credentials in the following format:
'region' => '',
'version' => '',
'access_key' => '',
'secret_key' => '',
Then in the file <module_path>/etc/queue.xml you need to update connection type into SQS.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/queue.xsd">
<broker topic="name.topic" type="sqs" exchange="magento">
<queue consumer="consumerName" name="queue.name"/>
Now it’s configured. The rest of it is described in the documents. The only thing you should pay attention to is to specify topology module dependency (belvg/module-sqs) in the setup file when installing the module. Here is the example:
* UpgradeSchema constructor.
* @param Topology $topology
public function __construct(Belvg\Sqs\Model\Topology $topology)
/** @var TYPE_NAME $topology */
$this->topology = $topology;
P.S. The module was tested on Magento 2.1.3-2.1.7 EE. Any bugs can be submitted to the repository https://github.com/Galillei/magento-sqs.