symfony-messenger
Installation
SKILL.md
Symfony Messenger (Symfony)
Use when
- Moving slow or failure-prone work out of the request into a message and an
#[AsMessageHandler]handler. - Choosing a transport (Doctrine, Redis, AMQP,
sync://,in-memory://) and routing messages to it. - Running, sizing, and restarting workers with
messenger:consume. - Making handlers safe under redelivery.
Default workflow
- Create the message as a plain
readonlyclass that carries IDs, never entities. - Write the handler with
#[AsMessageHandler]and a typed__invoke(): refetch by ID, skip work already done. - Route the message with
#[AsMessage('async')]or theroutingkey, and declare the transport DSN inmessenger.yaml. - Set
retry_strategyandfailure_transporton the transport. - Consume with
messenger:consume async -vv, bounded by--limit,--memory-limit, or--time-limit. - Check the wiring with
debug:messengerandmessenger:stats, and usein-memory://in tests.