Add daily email for 2024-07-17
Queuing long-running tasks
This commit is contained in:
parent
8fae6f6241
commit
000a3148d0
35
source/_daily_emails/2024-07-17.md
Normal file
35
source/_daily_emails/2024-07-17.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
title: Queuing long-running tasks
|
||||
date: 2024-07-17
|
||||
permalink: daily/2024/07/17/queuing-long-running-tasks
|
||||
tags:
|
||||
- software-development
|
||||
- drupal
|
||||
cta: ~
|
||||
snippet: |
|
||||
Do you have long-running tasks in your application? Have you tried using queues?
|
||||
---
|
||||
|
||||
Do you have long-running or performance-heavy tasks in your application?
|
||||
|
||||
What about performing complex actions when a user completes a task, such as submitting a form?
|
||||
|
||||
What if the action took several seconds or minutes to complete?
|
||||
|
||||
The user would assume their submission failed and may either leave or submit the form again and cause duplicate submissions.
|
||||
|
||||
Instead, maybe use a queue.
|
||||
|
||||
When the user submits the form, all you need to do is create a queue item for that submission and let the form submit as normal.
|
||||
|
||||
In the background, the queue items will be processed when they can take more time or memory to perform the tasks and without blocking the user - giving them a better experience.
|
||||
|
||||
Drupal supports queues by default, storing queue items in its database.
|
||||
|
||||
For an example, see the [Private Message Queue module][0] on Drupal.org.
|
||||
|
||||
I wrote it for a client project to use queues when sending private messages to event attendees, which could be hundreds per event.
|
||||
|
||||
Without a queue, the request would have taken a long time to complete, or likely timed out.
|
||||
|
||||
[0]: https://www.drupal.org/project/private_message_queue
|
Loading…
Reference in a new issue