46 lines
2.5 KiB
Markdown
46 lines
2.5 KiB
Markdown
# Messenger
|
|
|
|
The **Messenger** window (right tool bar, or Tools) is there in a Symfony project that requires `symfony/messenger`. It starts and
|
|
follows workers, shows the queues and the failed messages, edits `config/packages/messenger.yaml` as a form, and writes messages and
|
|
handlers. Four tabs.
|
|
|
|
Changes to files are **shown as diffs first** (one editor tab per file) and written by **Write the files**; nothing is written if a
|
|
file changed meanwhile.
|
|
|
|
## Workers
|
|
|
|

|
|
|
|
Start `messenger:consume` from the IDE: choose the transports, `--limit`, `--time-limit`, `--memory-limit`, then **Start a worker**.
|
|
Several workers can run at once, each with its live output (`-vv`), **Stop** and **Restart**. **Restart when it ends** relaunches a
|
|
worker that finished (not after 3 quick failures in a row). **Stop every worker** runs `messenger:stop-workers`; **Set up the
|
|
transports** runs `messenger:setup-transports`.
|
|
|
|
Where a worker runs follows the [Symfony console](symfony-console.md) runner: in the site's running PHP container, in a temporary
|
|
container of the site's image, or with the computer's PHP. Stop works in each case.
|
|
|
|
## Queues
|
|
|
|
The messages waiting in each transport (`messenger:stats`); the **failed messages** (id, class, date, error), each **retried** or
|
|
**removed**, or all at once; and, when `symfony/scheduler` is installed, the Scheduler's recurring messages with their next runs.
|
|
|
|
## Transports
|
|
|
|
The messenger.yaml file as a form: each transport's DSN (an `%env()%` DSN shows the value your `.env` files give it), retry
|
|
strategy and failure transport; the global failure transport; the **routing** (message class to transports). It is written with
|
|
symfony/yaml: the other keys and the `when@env` sections are kept, **comments are not** (the diff shows it).
|
|
|
|
## Messages
|
|
|
|
Every message (handled, routed, marked `#[AsMessage]`, or in `src/Message/`) with its **handlers** (`#[AsMessageHandler]` on a class
|
|
or methods, `bus`, `fromTransport`) and its transports; a message routed through a parent class or `*` is shown too. A message
|
|
**without handler** is pointed out.
|
|
|
|
- **New message**: the class, its routing (in messenger.yaml, or `#[AsMessage]`) and its handler.
|
|
- **Handler**: adds a handler to an existing message.
|
|
|
|
## Limits
|
|
|
|
- Queue figures need a transport that can count (`messenger:stats`); some DSNs cannot.
|
|
- Scheduler information needs `symfony/scheduler` and a working `debug:scheduler`.
|
|
- Comments of messenger.yaml are lost when the Transports tab writes the file.
|