From fbbb2b6b181aebf5239ff0fe63a4d6080d242e6b Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 27 Feb 2018 21:17:30 +0000 Subject: [PATCH] Update post --- ...27-queuing-private-messages-in-drupal-8.md | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/source/_posts/2018-02-27-queuing-private-messages-in-drupal-8.md b/source/_posts/2018-02-27-queuing-private-messages-in-drupal-8.md index 7656709f..a789b49f 100644 --- a/source/_posts/2018-02-27-queuing-private-messages-in-drupal-8.md +++ b/source/_posts/2018-02-27-queuing-private-messages-in-drupal-8.md @@ -5,15 +5,21 @@ tags: - drupal-8 - drupal-modules - drupal-planet + - open-source draft: true --- -[Private Message][0]. +{% block excerpt %} +My current project at [Microserve][0] is a Drupal 8 website that uses the [Private Message][1] module for users to send messages to each other. +In some cases though, the threads could contain hundreds of recipients so I decided that it would be good to queue the message requests so that they can be processed as part of a background process for better performance. The Private Message module does not include this, so I've written and released a separate [Private Message Queue][2] module. +{% endblock %} + +{% block content %} ## Queuing a Message The module provices a `PrivateMessageQueuer` service (`private_message_queue.queuer`) which queues the items via the `queue()` method. -The method accepts an array of `User` objects as the messsage recipients, the message body text and another user as the message owner. +The method accepts an array of `User` objects as the messsage recipients, the message body text and another user as the message owner. (I’m currently considering [whether to make the owner optional][4], and default to the current user if one is not specified) Here is an example: @@ -42,7 +48,7 @@ The module also provides a `PrivateMessageQueue` queue worker, which processes t It uses the `PrivateMessageThread` class from the Private Message module to find for an existing thread for the specified recipients, or creates a new thread if one isn't found. The new message is then added to the thread. -The queue is processed on each cron run, so I recommend adding a module like [Ultimate Cron][1] so that you can process the queued items frequently (e.g. every 15 minutes) and run the heavier tasks like checking for updates etc less frequently (e.g. once a day). +The queue is processed on each cron run, so I recommend adding a module like [Ultimate Cron][3] so that you can process the queued items frequently (e.g. every 15 minutes) and run the heavier tasks like checking for updates etc less frequently (e.g. once a day). You can also process the queue manually with Drush using the `drush queue-run ` command - e.g. `drush queue-run private_message_queue`. @@ -50,6 +56,10 @@ You can also process the queue manually with Drush using the `drush queue-run