Php sonataNotificationBundle,将电子邮件存储到数据库中,但不会触发swiftmailer消费者,也不会发送电子邮件
我集成了SonatanNotificationBundle,我将后端配置为条令,电子邮件被存储在数据库通知消息表中,但没有被发送 如何使用swiftmailer consumer从数据库发送电子邮件。下面是配置Php sonataNotificationBundle,将电子邮件存储到数据库中,但不会触发swiftmailer消费者,也不会发送电子邮件,php,symfony,symfony-sonata,Php,Symfony,Symfony Sonata,我集成了SonatanNotificationBundle,我将后端配置为条令,电子邮件被存储在数据库通知消息表中,但没有被发送 如何使用swiftmailer consumer从数据库发送电子邮件。下面是配置 sonata_notification: backend: sonata.notification.backend.doctrine backends: doctrine: message_manager: sonata.notif
sonata_notification:
backend: sonata.notification.backend.doctrine
backends:
doctrine:
message_manager: sonata.notification.manager.message.default
max_age: 86400 # max age in second
pause: 500000 # delay in microseconds
states: # raising errors level
in_progress: 10
error: 20
open: 100
done: 10000
日志中的查询始终搜索默认类型,即使我在backend start命令中提到--type=mailer
在consumer.yml中,我已将SwiftMailerConsumer注册为事件侦听器
<service id="sonata.notification.consumer.swift_mailer" class="Sonata\NotificationBundle\Consumer\SwiftMailerConsumer">
<tag name="sonata.notification.consumer" type="mailer" />
<tag name="sonata.notification.consumer.event_listener" event="default" method="process" />
<argument type="service" id="mailer" />
</service>
下面是日志
[2013-07-12 19:55:16]条令调试:选择t0.type为type1,t0.body为body2,t0.state为state3,t0.restart为STATE4,t0.created为created为at5,t0.updated为at6,t0.STATED为at7,t0.completed为at8,t0.id为id9,来自通知消息t0,其中t0.state=?和t0.type=?限制10[0,“默认”][]
我是否需要为mailer编写不同的后端并在config.yml中进行如下配置
sonata_notification:
backend: sonata.notification.backend.doctrine
consumer:
swift_mailer:
path: %kernel.root_dir%/../vendor/swiftmailer
backends:
doctrine:
message_manager: sonata.notification.manager.message.mailer
以下是swiftmailer消费者的SonatanNotificationBundle配置。无需对任何其他文件进行更改
sonata_notification:
backend: sonata.notification.backend.doctrine
queues:
- { queue: mailer, routing_key: mailer }
- { queue: catchall, default: true }
backends:
doctrine:
message_manager: sonata.notification.manager.message.default
max_age: 86400 # max age in second
pause: 500000 # delay in microseconds
states: # raising errors level
in_progress: 10
error: 20
open: 100
done: 10000
你启动命令了吗?是的,app/console sonata:notification:start--env=prod--iteration=250--type=email
sonata_notification:
backend: sonata.notification.backend.doctrine
queues:
- { queue: mailer, routing_key: mailer }
- { queue: catchall, default: true }
backends:
doctrine:
message_manager: sonata.notification.manager.message.default
max_age: 86400 # max age in second
pause: 500000 # delay in microseconds
states: # raising errors level
in_progress: 10
error: 20
open: 100
done: 10000