我期待使用水星与RabbitMQ。这是我第一次使用水星以及RabbitMQ,所以我还不是很好。
以下是我的处境:
我安装了Mercure和Messenger。
Messenger.yaml
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async: '%env(MESSENGER_TRANSPORT_DSN)%'
failed: '%env(MESSENGER_TRANSPORT_FAILED_DSN)%'
# sync: 'sync://'
routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async.env
MERCURE_PUBLISH_URL=http://localhost:3000/.well-known/mercure
MERCURE_JWT_TOKEN=aVerySecretKey
MESSENGER_TRANSPORT_DSN=amqp://bastien:mypassword@localhost:5672/%2f/messages
MESSENGER_TRANSPORT_FAILED_DSN=amqp://bastien:mypassword@localhost:5672/%2f/failed在我的控制器中,我在本地应用程序的URL上模拟了50个页面:
/**
* @Route("/ping", name="ping", methods={"POST"})
*/
public function ping(MessageBusInterface $bus)
{
for($i=0;$i<=50;$i++)
{
$update = new Update("http://monsite.com/ping", "[]");
$bus->dispatch($update);
}
return $this->redirectToRoute('home');
}我已经成功地启动了我的水星以及信使的实例,因此它与我的RabbitMQ连接得很好。
但是,当我测试发送pings时,它可以工作,但不需要通过我的RabbitMQ。我错过了什么吗?我在路由部分想到了我的Messenger.yaml,但如果是这样的话,我不知道该怎么写
发布于 2020-12-03 09:30:58
默认情况下,消息在信使中同步执行。
您需要配置messenger.yaml中的更新消息以使用异步传输:
Symfony\Component\Mercure\Update: asynchttps://stackoverflow.com/questions/65109544
复制相似问题