2

I am wondering if Craft/Yii has some sort of built in queuing system for apps that need to do additional processing that could hang up the UI or make the user wait unnecessarily. I am looking for something similar to Laravel Queues. Does Craft have something similar built in? If not, I think queues would make a great addition to the API.

http://laravel.com/docs/queues

4

Not so much true queues, but Craft does have the (completely undocumented) concept of Tasks, which are meant to be used for potentially long running tasks that don't need to execute immediately. Plugins can create and register tasks to run.

Here are some questions discussing them:

My tasks don't seem to be running as a background process

How to add a subTask to an already running Task?

Triggering the start of a task from a CRON job

You can view the TaskService in craft/app/services/TaskService.php and you can see examples of Craft's own tasks in craft/app/tasks.

Also worth noting that proper support for queues at the framework level looks like it's on the roadmap for Yii 2.1.

3
  • Awesome Brad. Thanks a lot for your help with all my plugin dev questions. Aug 19 '14 at 17:30
  • Are the tasks executed at browser reload by the user or how is the integration done server-side? (How much can the tasks "handle" before a custom CRON-setup would be more ideal?) Aug 20 '14 at 14:14
  • 1
    @naboovalley Currently executed by the next CP request, but you could easily write a plugin exposes a controller action that a CRON job could trigger.
    – Brad Bell
    Aug 20 '14 at 15:49
2

Craft 3 now uses a job queue powered by the Yii2 Queue Extension.

Some info in Craft 3 Docs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.