Question

Is there a way to add RabbitMQ/AMQP setup to an existing M2 EE installation? All the docs seem to shout that it has to be done at install time but that seems a bit limiting. However, I can't find anywhere in the admin to configure host, port etc.

Was it helpful?

Solution

The following steps should help:

  1. Add the following element to array in app/etc/env.php:

    'queue' => [ 'amqp' => [ 'host' => 'localhost', 'port' => '5672', 'user' => 'guest', 'password' => 'guest', 'virtualhost' => '/', 'ssl' => '' ] ]

  2. Make sure exchanges, queues and exchange-to-queue mappings are configured properly on RabbitMQ side. At the moment this is done only once when AMQP module is installed. However, it is possible to initiate RabbitMQ configuration process by calling \Magento\Amqp\Model\Topology::install. RabbitMQ management plugin is a good tool to view current configuration

At the moment RabbitMQ support is implemented on very basic level and is going to be improved in scope of the nearest Magento releases. The best option for now is to reinstall Magento if possible.

OTHER TIPS

This looks to be built in now in 2.1.7+ (maybe earlier?). But if you still need this, I tested with this and it works:

<?php

namespace MyNamespace\MyModule\Setup;

use Magento\Amqp\Model\Topology;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;

class InstallSchema implements InstallSchemaInterface
{
    /**
     * @var Topology
     */
    private $topology;

    /**
     * InstallData constructor.
     */
    public function __construct(Topology $topology)
    {
        $this->topology = $topology;
    }


    /**
     * Installs DB schema for a module
     *
     * @param SchemaSetupInterface   $setup
     * @param ModuleContextInterface $context
     *
     * @return void
     */
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        $this->topology->install();
        $setup->endSetup();
    }
}

All setup:install commands can be changed using setup:store-config:set.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top