Appointments plugin has always used WP-cron to schedule email notifications and reminders to customers. Although, it’s pretty simple and worked so far, it can become clogged, slow and unreliable. This is why we replaced it with Action Scheduler, which is better in every single way. It is also rock-solid and used by main WooCommerce plugins, like Subscriptions and Follow Ups, so we’re really happy to add it to Appointments as well.
Why Action Scheduler?
It works much better than than WP-cron and is more robust job queue engine that handles a lot of chronological tasks better. Default cron engine that is bundled with WordPress is pretty fine for small tasks, like running updates, but if you require a more reliable and scalable task system, it is not suitable. Below are the most obvious advantages.
Batch Processing
When there are multiple email notifications/reminders to be processed, Action Scheduler will process them in a batch of 20 instead of all at once. This makes sure your PHP memory is not exhausted. It can also process more than one batch at a time and will continue until all actions are processed using a maximum of 5 concurrent queues. This makes sure all appointment notifications are always sent on time and are always sent, even when there are batches of 100,000 notifications in queue.
Control over Notifications
You can view past notifications or run/cancel all future notifications, before they are sent out. Previously, you had no insights into notifications being sent out and could not cancel already scheduled notifications. This is now a lot easier and puts you in control.
Record Keeping & Clearing
All events for each action will be logged in the comments table. You can see past and future events inside: WooCommerce > Status > Scheduled Actions. To make sure log record doesn’t clog the database, there are a lot of housekeeping switches:
- Removal of any existing claims on actions which have been sitting in a queue for more than 5 minutes.
- Trashing any actions which were completed more than 1 month ago.
- Actions running more than 5 minutes will be timed out and marked as failed. However, if all callbacks attached to the action were successfully completed sometime after that 5 minute timeout, its status would later be updated to completed.
Manage Scheduled Notifications
You can view past and future notifications inside:
WooCommerce > Status > Scheduled Actions.
You can do the following tasks with scheduled actions:
- Run a pending action.
- View the scheduled actions with a specific status, like the all actions which have failed or are in-progress.
- View the completed actions, excellent when testing if everything works as planned.
- View the log entries for a specific action to find out why it failed.
- Sort scheduled actions by hook name, scheduled date, claim ID or group name.
Action Scheduler 3.0+
Version 3.0 is a heavily improved library that works even faster since all the events are stored in separate tables in the database. There are numerous bug fixes and improvements introduced with this version. The best feature introduced is the Async Queue Runner, which reduces reliance on WP-cron even further and also runs tasks much more reliably. Version 3.1 is also From WooCommerce 4.0, version 3.1 is bundled with the e-commerce plugin, which makes your store even more performant.
Gabi says
Where are the “housekeeping switches”??? I have 1000+ old records which seem to be basicallly … worthless.
Zeljan Topic says
We have added functions to clean up old records after we switched to Action Scheduler. If any still remain, please contact us and let us know which records are still remaining and we’ll add the cleanup with upcoming plugin update.