Jun'uary

The best background processing lib for Rails

Jan 发表于 2008-08-25 15:27:28

In many case you need to deal with something in the background. In background means you do the things in a process or thread other than the one Rails is running in. One example is file uploading, if you don't do it in background your Rails will be blocked in the entire uploading period and won't be able to process any request. (For file uploading, in-background is not the only solution, check the more cooler one here)

There's many libraries to help ppl do things in background such as BackgrounDRB and BackgroundJob(BJ). BackgrounDRB has been rewritten and it's stable enough now, but it's VERY complicated for simple task. You need lots of configuration files and daemons to make it run. BackgroundJob is much more simpler, that's why it exists. Here's a great summary on this two probject by Ezra, author of merb framework.

Unfortunately, BJ can't work with aged rails, like rails 1.1.6. The main reason is that they all depend on a class named OrderedHash. Rails 1.1.6 implement its own OrderedHash while BJ depends on orderedhash gem. In latest rails the OrderedHash used by rails itself is wrapped in a namespace so there won't be any problem.

So if you want to use BJ in an old rails version like me, try the modified BJ, it contains the source of all depends,  including a modified version of orderedhash. Just install as rails plugin like normal BJ library.

script/install http://bj-on-old-rails.rubyforge.org/svn/

And if you're patient enough to reach here, aha, you're lucky :). What I want to say is neither BDRB or BJ is the best solution for simple task, Spwan is. It will just fork()(on UNIX platform) or Thread.new()(on Windows or JRuby) for your background job, zero configuration, no daemon, work perfect and compatible with old rails.



收藏: QQ书签 del.icio.us 订阅: Google 抓虾

最新评论

发表评论

* 昵称

已经注册过? 请登录

新用户请先注册 以便能显示头像及追踪评论回复

Email
网址
* 评论
表情
 
 

分类小组论坛
杂谈, 娱乐、八卦, 文学、艺术, 体育, 旅游、同城, 象牙塔, 情感, 时尚、生活, 星座, 科技

请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

相关法律法规
全国人大常委会关于维护互联网安全的决定
中华人民共和国计算机信息系统安全保护条例
中华人民共和国计算机信息网络国际联网管理暂行规定
计算机信息网络国际联网安全保护管理办法
计算机信息系统国际联网保密管理规定

Jan'uary

人类一思考,老夫就发笑

搜索

日历