Implementation of Symfony Messenger

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?

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

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