Plugins - Asynchronous
Add to favoritesNow you can make any method in one of your models asynchronous. For example,
class TestRecord < ActiveRecord::Base
after_save :an_alert
def an_alert
logger.info 'We could now asynchronously send an email to tons of people with this alert.'
end
asynchronous :an_alert
end
That’s it, just install the plugin, add a ‘QueuedMethods’ table (follow my migration script), and add the ‘asynchronous :symbol’ part below where you declare the method you are making asynchronous. I’ve included a migration script in the db folder to use for the QueuedMethods table.
To process your queue just set up a cron job using the script runner:
script/runner 'MethodQueue.process' -e production
http://code.google.com/p/asynchronous/
http://asynchronous.googlecode.com/svn/trunk/
Rails' (MIT)
Model

A sample app would be helpful in understanding how this works. Sending batched emails for example.