D
D
Dos2020-10-20 00:51:45
symfony
Dos, 2020-10-20 00:51:45

How to connect Symfony Messenger?

Hello! Who is familiar with Messenger from Symfony - can you tell me how to set up a transport for RabbitMQ? The only caveat - I want to use it not in the symphony. That's why I'm asking. Now I configured only synchronous requests:

$configApp['params']['message_bus'] = [
    'handlers' => [
        Message::class => [Handler::class],
    ],
];
MessageBusInterface::class => function (Container $container) use ($configApp) {
    $config = $configApp['params']['message_bus'];
    $handlers = [];
    foreach ($config['handlers'] as $message => $handlers) {
        foreach ($handlers as $handler)  {
            $handlers[$message][] = $container->get($handler);
        }
    }
    return new MessageBus([
        new HandleMessageMiddleware(new HandlersLocator($handlers)),
    ]);
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question