Download the PHP package zenstruck/messenger-monitor-bundle without Composer
On this page you can find all versions of the php package zenstruck/messenger-monitor-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zenstruck/messenger-monitor-bundle
More information about zenstruck/messenger-monitor-bundle
Files in zenstruck/messenger-monitor-bundle
Package messenger-monitor-bundle
Short Description Batteries included UI to monitor your Messenger workers, transports, schedules, and messages.
License MIT
Homepage https://github.com/zenstruck/messenger-monitor-bundle
Informations about the package messenger-monitor-bundle
zenstruck/messenger-monitor-bundle
Batteries included UI to monitor your Messenger workers, transports, schedules, and messages.
If the packaged UI is not to your liking, you can easily build your own with the provided tools.
Installation
messenger:monitor
Command
With zero configuration, you can run the messenger:monitor
command to see information
about your running workers and transports. If storage is configured, it displays a
historical snapshot whose period can be customized with the --period
option.
Storage
[!NOTE] This step is required to use the History.
[!NOTE] Only Doctrine ORM is currently available as a storage engine.
Configuration
-
Create a
ProcessedMessage
entity that extendsZenstruck\Messenger\Monitor\History\Model\ProcessedMessage
in your app: -
Add the entity class to the bundle config:
-
Clear Cache:
- Create and execute the migration:
Usage
Once configured, consumed messages are tracked and saved. These processed messages contain a lot of useful information and can be viewed in the user interface or the provided tools.
Disable Monitoring
You may want to disable monitoring for certain messages. There are two ways to do this:
-
When dispatching the message, add the
DisableMonitoringStamp
: -
Add the
DisableMonitoringStamp
as a class attribute to your message: - You may want to disable monitoring for messages that are dispatched without any handler.
You can do this by using the
DisableMonitoringStamp
with optional constructor argumenttrue
:
Description
The stored ProcessedMessage
has a description property. This is helpful to differentiate between
messages in the user interface. By default, this is the stringified version of the message object
(if it implements \Stringable
). You can add the DescriptionStamp
to customize:
Tags
To help with filtering processed messages, they can have one or more tags. Some tags
are added automatically (like schedule
if it's a scheduled message) but you can also
add your own in one of two ways:
-
When dispatching the message, add one or more
TagStamp
's: - Add the
TagStamp
as a class attribute to your message:
messenger:monitor:purge
Command
If your app handles a lot of messages, the processed message database table will get very large.
The messenger:monitor:purge
clears messages older than a specific date:
See Period
for allowed values.
[!NOTE] Schedule this command to run daily with
symfony/scheduler
andRunCommandMessage
.
messenger:monitor:schedule:purge
Command
If using symfony/scheduler
, you might want to keep a specific # of these messages as they might run
very infrequently. When running messenger:monitor:purge
, add the --exclude-schedules
option to
avoid deleting schedule history. Then run messenger:monitor:schedule:purge
to keep a specific number
(10 by default) of task run histories.
Use the --remove-orphans
option to delete schedule task runs that are no longer associated with a schedule.
[!NOTE] Schedule this command to run daily with
symfony/schedule
andRunCommandMessage
.
User Interface
[!NOTE]
symfony/form
(composer require symfony/form
) is required for the UI.[!NOTE] If using
symfony/scheduler
and the UI,symfony/security-csrf
(composer require symfony/security-csrf
) is required. CSRF protection and sessions must also be enabled in yourconfig/packages/framework.yaml
.[!NOTE] Storage must be configured for this feature.
Create a controller that extends Zenstruck\Messenger\Monitor\Controller\MessengerMonitorController
in your app:
You can now access the dashboard at: /admin/messenger
or with the route zenstruck_messenger_monitor_dashboard
.
[!WARNING] It is important that your
MessengerMonitorController
is only accessible by site administrators as it contains sensitive application information. Use either theIsGranted
attribute on your controller as shown above and/or ensure the controller is behind an access-controlled firewall that only allows site administrators.[!NOTE] Install
knplabs/knp-time-bundle
(composer require knplabs/knp-time-bundle
) to display friendlier times and durations in the UI.[!NOTE] Install
lorisleiva/cron-translator
(composer require lorisleiva/cron-translator
) to display friendlier CRON values for your scheduled tasks.
Advanced Usage
Workers
Service
WorkerInfo
Transports
Service
TransportInfo
QueuedMessage
Schedules
Service
ScheduleInfo
TaskInfo
MessageInfo
TriggerInfo
History
[!NOTE] Storage must be configured for this feature.
Storage
Service
Specification
Snapshot
Others
Hide Log-Entries
While you run php bin/console messenger:consume async [-vv]
you see a lot of messages like this one.
If you want to not display them, you can disable them with adding "!cache"
to the console-channels in config/packages/monolog.yaml
Full Default Bundle Configuration
All versions of messenger-monitor-bundle with dependencies
symfony/framework-bundle Version ^6.4|^7.0
symfony/messenger Version ^6.4|^7.0
zenstruck/bytes Version ^1.0
zenstruck/collection Version ^0.4