Plugins - Asynchronous

StarAdd to favorites

Now 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

Nate Kontny

http://code.google.com/p/asynchronous/

http://asynchronous.googlecode.com/svn/trunk/

Rails' (MIT)

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment
anon 15 Aug 2006

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

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?