问题描述
我正在用 symfony 4.4 构建一个应用程序。我使用 Messenger 异步发送电子邮件。在我的开发计算机上,一切都像魅力一样。但是在我的服务器(debian VPS)上出了点问题。
当我尝试发送电子邮件时,我的消息由原则处理和存储(select * from messenger_messages 返回 1 行包含我刚刚发送的消息)。但是当我运行 PHP bin/console messenger:consume async
时什么也没有发生。 Worker 启动并保持等待,就好像数据库中没有消息一样。
如果有人可以帮助...
messenger.yaml
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async: '%env(MESSENGER_TRANSPORT_DSN)%'
# Failed: 'doctrine://default?queue_name=Failed'
# sync: 'sync://'
async_priority_high:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
# default configuration
retry_strategy:
max_retries: 3
# milliseconds delay
delay: 1000
# causes the delay to be higher before each retry
# e.g. 1 second delay,2 seconds,4 seconds
multiplier: 2
max_delay: 0
# override all of this with a service that
# implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
# service: null
routing:
# Route your messages to the transports
'App\Service\Email\EmailMessage': async
.env
MESSENGER_TRANSPORT_DSN=doctrine://default
解决方法
已解决
事实上,一切正常,但延迟了 1 小时...... Mysql 和系统时区 x 不同 :-( !