Jun'uary
Jan'uary » 日志 » The best background processing lib for Rails
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.
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.
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.
曾经的这一天...
- » 2005年: 还是Google
- » 2005年: Is India's outsourcing honeymoon over?
- » 2005年: Windows 95 十周年
- » 2005年: Sylpheed 2.0.0 released (GTK2)
- » 2005年: Google Talk虽然用的Jabber协议,但是不能和其他Jabber Server通信
- » 2005年: Open Source Marketing?
- » 2005年: 如果你要加入WTO, 那么开源软件是个好的选择
相关日志:
收藏:
QQ书签
del.icio.us
订阅:
Google
抓虾
