# Implementation of Symfony Messenger

**URL:** <https://forum.oxid-esales.com/t/implementation-of-symfony-messenger/97032>\
**Category:** English forums\
**Tags:** development\
**Created:** [August 26, 2020, 1:14pm UTC](https://forum.oxid-esales.com/t/implementation-of-symfony-messenger/97032 "2020-08-26T13:14:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mateusz\_Mierzynski](https://forum.oxid-esales.com/user_avatar/forum.oxid-esales.com/mateusz_mierzynski/32/1575_2.png) [@Mateusz\_Mierzynski](https://forum.oxid-esales.com/u/Mateusz_Mierzynski)\
**Post date:** [August 26, 2020, 1:14pm UTC](https://forum.oxid-esales.com/t/implementation-of-symfony-messenger/97032/1 "2020-08-26T13:14:35Z")

</div>

Hello,  
I have a question about your experience with Symfony Messenger in OXID.  
At the moment I write a module to sync data with external service and I want to do it asynchronously with Symfony Messenger component, but I stuck with the problem of how to consume messages in the queue. I added messenger to a composer.json file and I install it in module.

In the controller I used the following code to add a message to the queue:

```
$senderLocator = new class implements SendersLocatorInterface{

                public function getSenders(Envelope $envelope): iterable
                {
                    $conn = DriverManager::getConnection([
                        'driver' => 'pdo_mysql',
                        'host' => 'localhost',
                        'dbname' => 'db',
                        'user' => 'licouser01',
                        'password' => 'password',
                        'port' => 3306,
                    ]);

                    $connection = new Connection([
                        'hosts' => 'localhost',
                        'ports' => '3306',
                        'vhost' => '/',
                        'login' => 'licouser01',
                        'password' => 'password'
                    ],
                        $conn
                    );

                    return [
                        'async' => new DoctrineSender($connection)
                    ];
                }
            };

            $middleware = new SendMessageMiddleware($senderLocator);

            $bus = new MessageBus([$middleware]);

            $envelope = $bus->dispatch(new Test(test'));

```

New messages are stored in messenger\_messages database table. Unfortunately, I cannot execute command to consume messages.  
At the beginning I tried to use oxrun tool but Symfony component causes an error:

> Command Collection: Error loading class ‘Symfony\Component\Messenger\Command\SetupTransportsCommand’. Trace: Oxrun\CommandCollection\Aggregator\ModulePass

Did you implement this component in OXID module and how did you solve problems with DependencyInjection?

---

<div class="post-metadata">

**Author:** ![Mateusz\_Mierzynski](https://forum.oxid-esales.com/user_avatar/forum.oxid-esales.com/mateusz_mierzynski/32/1575_2.png) [@Mateusz\_Mierzynski](https://forum.oxid-esales.com/u/Mateusz_Mierzynski)\
**Post date:** [August 26, 2020, 1:17pm UTC](https://forum.oxid-esales.com/t/implementation-of-symfony-messenger/97032/2 "2020-08-26T13:17:09Z")

</div>

I forgot:  
OXID v6.1.6  
Symfony Messenger: v4.4.11

---

<div class="post-metadata">

**Author:** ![system](https://forum.oxid-esales.com/user_avatar/forum.oxid-esales.com/system/32/4245_2.png) [@system](https://forum.oxid-esales.com/u/system)\
**Post date:** [August 26, 2021, 1:17pm UTC](https://forum.oxid-esales.com/t/implementation-of-symfony-messenger/97032/3 "2021-08-26T13:17:10Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
