[EXTENSION] celery-yii

http://www.yiiframework.com/extension/celery-yii/

Enjoy!

Looks interesting.

As I read at celery project page:

I would appreciate if you’d share which way do you use this extension (usage case(s)) also.

Thank you.

Thanks for the feedback.

I basically use celery for every task that I can outsource to a backend, which means that the result of this task is not required to render the view.

To give you an example related to the Yii blog tutorial: http://www.yiiframework.com/doc/blog/1.1/en/post.create




protected function afterSave()

{

    parent::afterSave();

    Tag::model()->updateFrequency($this->_oldTags, $this->tags);

}



I would rather implement Tag::updateFrequency() via Celery, as the exact frequency of the tags is not actually needed by post/create (or post/update) view.

When your project grows in size, in this way you reduce the possibility of errors (maybe creating a post fails because of a problem in the tags table) and the time a user has to wait until her request is processed.

Another classical example is notifications. Assume that, when a user creates a post, you want to add a notification to all her friends/followers. If you implement everything in the front end, a user with many friends should wait longer than one with a few of them, because it takes time to update all the records. Outsourcing to the backend, the user immediately creates the post, and the friends shall be notified asynchronously.

I’ve started using RabbitMQ (with the Yii AMQP extension) but I ended up switching to Celery simply because you don’t just need a channel to send tasks to the backend (this is what rabbit is), but you also need a way to control your tasks, decide how they can communicate, manage their errors… in one word, you need to reimplement Celery.

The only drawback is that it’s in python, so your backend must use a different programming language, but for me this was a requirement :wink:

Thank you very much for the additional description.

I’ve updated the extension to version 0.2. The only change is in the licence, now BSD 2-clause license.

Meanwhile, I’ve tested it on Celery 3.0.4. Enjoy!