Skip to content

Messenger is the solution for sending messages asynchronously. That is, a notification and recipient are stored in a separate system then dispatched outside a web request. This improves performance of a web request, in both time and memory.

When the Drupal Symfony Messenger project is installed, Notifier will automatically send messages via the Symfony Messenger component.

Running messenger ​

Ensure your system is executing the messenger command, otherwise your notifications will get stuck unsent.

Local development

For local development, you can run sm messenger:consume asynchronous.

INFO

If vendor binaries have not been added to PATH, you may need to prefix the command, such as vendor/bin/sm or bin/sm depending on your Composer setup.

Production development

For production deployments, running sm messenger:consume asynchronous is preferred. However, if your production infrastructure does not support long-running processes, you can replicate drush cron or drush queue:run behavior where the command exits after a period of time or other criteria by adding flags:

sh
sm messenger:consume asynchronous \
  --limit=256 \ 
  --time-limit=120 \ 
  --memory-limit=128M

Recommended flags:

  • --limit — exit after this number of messages have been processed.
  • --time-limit — exit after this amount of seconds have passed.
  • --memory-limit — exit after this amount of peak memory has been reached.