8

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.

7

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.

  • Thanks, I ran the setup and found the env.php settings but didn't know about the topology install step. That may be why my test is doing nothing. – robjingram Dec 17 '15 at 20:25
  • 1
    Just noting that the above was the case. I forced the AMQP setup to run again by removing it from setup_module and my queues then showed up in the RabbitMQ manager – robjingram Dec 20 '15 at 19:48
  • You can actually inject Magento\Amqp\Model\Topology into your own module UpgradeData and invoke $this->topology->install() method from there without stressing setup_module table. – cheelahim Jan 12 '16 at 14:18
0

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();
    }
}
-1

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

  • The help for that command lists some parameters that I can set such as --base-url but how sould I use it to set any of the options listed on devdocs.magento.com/guides/v2.0/install-gde/prereq/…? For example, if I pass --amqp-host I get an error that the option doesn't exist. – robjingram Dec 17 '15 at 0:50
  • Well, I was almost sure about that. I can't test it directly because i don't have an EE version to test, you can may try to make an fresh install (in other place) with using these parameters options and then take a look at /app/etc/env.php... i'm prety sure that such kind of local configurations are stored on this file. – MauroNigrele Dec 17 '15 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.