Tracking a specific queue completion
Hi all!
I have a question about the best way to track a queue completion - I have a feature on my app that runs bulk actions. Every time a bulk action is initiated, a queue with a specific name is created.
Currently, what I'm doing is using a model to track the completion - So I'm basically updating a record with the total queues/completed queues, then I trigger an action when total == completed.
Of course this is very error-prone (if one action fails, the "complete" action is never triggered) and limits me to run one action at a time to make sure the counter is updated correctly.
Is there a better way to achieve this?
2 Replies
Hello,
You could possibly use a scheduled action that runs often (each 5 or 15 minutes). In that action, check the status of all in process (or perceived to be) background actions. Once you have the results, update the value in the database.
Hey, I was scrolling through search to see if there was an answer for this. Since the queue could finish in 5 seconds or 5 hours a scheduled action isn't great.
My current solution is to check if any rows are still processing, if not then queue up the "complete" action. In my case the complete action is idempotent so if multiple queued actions finish at the same time it is okay to call the complete action multiple times.
It would be nice to have an event or an API endpoint to check queue length and status