# How can we set Shopware 6 to work with RabbitMQ?

**URL:** <https://forum.shopware.com/t/how-can-we-set-shopware-6-to-work-with-rabbitmq/70051>\
**Category:** Programming (EN)\
**Created:** [6. Oktober 2020 um 09:04 UTC](https://forum.shopware.com/t/how-can-we-set-shopware-6-to-work-with-rabbitmq/70051 "2020-10-06T09:04:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SorinSologics2019](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@SorinSologics2019](https://forum.shopware.com/u/SorinSologics2019)\
**Post date:** [6. Oktober 2020 um 09:04 UTC](https://forum.shopware.com/t/how-can-we-set-shopware-6-to-work-with-rabbitmq/70051/1 "2020-10-06T09:04:40Z")

</div>

Hello all. Does anyone knows how to set RabbitMQ to work togheter with Shopware 6 instead of default transport messaging? As starting point I had a look on vendor/shopware/core/Framework/Resources/config/packages/enqueue.yaml and vendor/shopware/core/Framework/Resources/config/packages/framework.yaml. I’m not sure how to specify sw6 to use rabbitMQ driver and how to set the queue name and other required parameters like host,port,…

We’ve tried to set in&nbsp;vendor/shopware/core/Framework/Resources/config/packages/enqueue.yaml:

```
enqueue:
    default:
        transport:
            dsn: "stomp+rabbitmq://guest:guest@localhost:5672"
            factory_service: Shopware\Core\Framework\MessageQueue\Enqueue\ConnectionFactoryFactory
        client: ~

```

But we have the following error:

“Attempted to load class “Client” from namespace “RabbitMq\ManagementApi”.↵Did you forget a “use” statement…”

vendor/enqueue/enqueue/Client/Driver/StompManagementClient.php on line 27. Seems the&nbsp;

```
 RabbitMq\ManagementApi\Client doesn't exists

```

Any help will be appreciated. Thank you!

&nbsp;

---

<div class="post-metadata">

**Author:** ![SorinSologics2019](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@SorinSologics2019](https://forum.shopware.com/u/SorinSologics2019)\
**Post date:** [7. Oktober 2020 um 08:29 UTC](https://forum.shopware.com/t/how-can-we-set-shopware-6-to-work-with-rabbitmq/70051/2 "2020-10-07T08:29:38Z")

</div>

Hello,

I’ve managed to make it work and just want to share it with you. Steps are:

Inside your plugin main file MyPlugin.php:

```
buildConfig($container);
    }

    private function buildConfig(ContainerBuilder $container): void
    {
        $locator = new FileLocator('Resources/config');

        $resolver = new LoaderResolver([
            new XmlFileLoader($container, $locator),
            new YamlFileLoader($container, $locator),
            new IniFileLoader($container, $locator),
            new PhpFileLoader($container, $locator),
            new GlobFileLoader($container, $locator),
            new DirectoryLoader($container, $locator),
            new ClosureLoader($container),
        ]);

        $configLoader = new DelegatingLoader($resolver);

        $confDir = $this->getPath() . '/Resources/config';

        $configLoader->load($confDir . '/{packages}/*' . Kernel::CONFIG_EXTS, 'glob');

        $env = $container->getParameter('kernel.environment');
        $configLoader->load($confDir . '/{packages}/' . $env . '/*' . Kernel::CONFIG_EXTS, 'glob');
    }
}

```

This will load up not only from xml file but also from yaml…

Add yaml files into /src/Resources/config/packages directory

enqueue.yaml:

```
enqueue:
    rabbitmq:
        transport:
            dsn: "%env(string:default:default_whitespace:SHOPWARE_RABBITMQ_ENQUEUE_DSN)%"
        client: ~

```

framework.yaml:

```
 framework: messenger: transports: default: dsn: "%env(string:default:default\_whitespace:SHOPWARE\_RABBITMQ\_FRAMEWORK\_DSN)%"

```

.env:

```
 SHOPWARE\_RABBITMQ\_ENQUEUE\_DSN=amqp://guest:guest@rabbitmq-hostt:5672/%2F?connection\_timeout=1000&heartbeat=100 SHOPWARE\_RABBITMQ\_FRAMEWORK\_DSN=enqueue://rabbitmq?queue[name]=my-queue

```

where ‘my-queue’ is the&nbsp;queue **&nbsp;** created in RabbitMQ Management interface.

Additionaly you could disable the admin worker by adding a shopware.yaml file into /src/Resources/config/packages:

shopware.yaml:

```
shopware:
  admin_worker:
    enable_admin_worker: false

```

But be sure to consume the queue messages by calling/setting a cron that will do bin/console messenger:consume

Regards,

Sorin
