For arlanix/notification 1.0.1
Multichannel Store Notifications documentation
This documentation is for developers. Use it to install and maintain the modules, or to publish notifications from your own module. Store staff create topics, subscriptions and rules in the admin. The manual is written for them.
Requirements
You need the following:
- Magento Open Source or Adobe Commerce 2.4.7 or later.
- PHP 8.1, 8.2, 8.3, 8.4 or 8.5.
- A working Magento cron. The cron starts the message queue consumers (
cron_consumers_runner). You can run the consumer under supervisor instead. - For email, either Magento's own mail must work, or the store must be able to reach an SMTP server.
- For Telegram, Slack and Discord, the store must be able to reach
api.telegram.org,hooks.slack.comanddiscord.comover HTTPS.
You do not need RabbitMQ. Without it, Magento uses its MySQL queue.
Packages
arlanix/notification is a metapackage. It installs every package in the following table at matching versions. To leave a module out, require the packages you need one by one instead.
| Package | Module | Purpose |
|---|---|---|
arlanix/module-core |
Arlanix_Core |
Code that every Arlanix module uses: logging, templates and the support bundle. |
arlanix/module-notification |
Arlanix_Notification |
Topics, subscriptions, rules, the Message Log, publishing, and delivery through the message queue. |
arlanix/module-notification-smtp |
Arlanix_NotificationSmtp |
Email, through Magento's mail or a separate SMTP server. |
arlanix/module-notification-telegram |
Arlanix_NotificationTelegram |
Telegram, through the store's bot or a bot set on the subscription. |
arlanix/module-notification-slack |
Arlanix_NotificationSlack |
Slack, through the channel's incoming webhook. |
arlanix/module-notification-discord |
Arlanix_NotificationDiscord |
Discord, through the channel's webhook. |
arlanix/module-notification-event |
Arlanix_NotificationEvent |
Store events for rules: orders, invoices, refunds, shipments, customers, reviews, newsletter subscriptions and the contact form. |
arlanix/module-notification-monitoring |
Arlanix_NotificationMonitoring |
Store health events for rules: admin sign-ins, cron, indexers, errors, orders that stop, imports and exports. It also adds a health check URL. |
How a message is delivered
A message goes through four stages:
Emit or publish. A module emits one of its declared events through
Arlanix\Notification\Api\EmitterInterface, or dispatches the Magento eventarlanix_notification_emit. Each active rule for that event checks its conditions. When they match, the rule publishes its message to its topic. A module can also publish a message directly, throughPublisherInterface::publish()or the eventarlanix_notification_publish.In both cases, the message is saved in
arlanix_notification_message. A row is added toarlanix_notification_deliveryfor each active subscription of the topic whose minimum severity the message meets. The id of each delivery is published to the queue topicarlanix.notification.deliver.Neither call throws an exception or waits for a mail server or a chat service. Only a message sent at once without the queue, such as Cron stopped, waits for its delivery. See Publish from your module.
Merge. The consumer
arlanix_notification_deliverreads up to 100 queue messages at a time and passes them to its handler together. The handler groups them by subscription. All deliveries for one subscription in a batch are sent as one digest. A digest holds up to 25 entries, and more entries are split into several digests. A message published several times is one entry.Deliver. The consumer claims each delivery before it sends it. So a queue message that arrives twice is sent only once. The subscription's protocol (email, Telegram, Slack or Discord) sends the digest. When sending fails, the delivery stores the error and the time of the next attempt.
Retry. The cron job
arlanix_notification_requeueputs deliveries back on the queue in three cases. The retry of a failed delivery is due. A consumer stopped while it was sending the delivery. The queue message of the delivery was lost.
For details, see Queue, cron and command line.
Pages
The documentation has the following pages:
- Install: Composer, the upgrade, the consumer, email, admin roles, and a test message before you hand over to the store.
- Email: Magento's mail or a separate SMTP server, encryption, and how to check it.
- Telegram, Slack and Discord: the bot token, a Bot API server, the hosts the store must reach, and where secrets are stored.
- Monitoring: what the module watches, the health check URL for an uptime monitor, and the data it stores.
- Upgrade and remove: how to move to a new version, and how to remove the modules.
- Queue, cron and command line: the consumer, how deliveries are merged, running several consumers, the cron jobs and the commands.
- Configuration: every setting with its default, and how to set one from the command line.
- Troubleshooting: messages that wait, deliveries that fail, and rules that send nothing.
- Publish from your module: the PHP API, the events, and a topic select in your module's settings.
- Declare events: how to offer your module's events to the store's rules.
- Customise messages: how to add a field to another module's event, add a
{message.*}variable or a modifier, or show a value differently. - Add a protocol: how to deliver through Microsoft Teams, SMS or another channel of your own.