The Ruby on Rails and ClojureScript experts

Sep 5, 2012

The link below explains how to make a Ruby instance method backgroundable in Torquebox. Tobey Crawley told me via the mailing list how to make class methods backgroundable by including the Backgroundable Module into the class’ singleton class:

class Thing

  class « self

    include TorqueBox::Messaging::Backgroundable

    def foo

      # do something

    end

    always_background :foo

  end

end

Thing.foo # will always be backgrounded.

Note: make sure to call always_background after the method is defined. There is a ticket to fix this limitation: https://issues.jboss.org/browse/TORQUE-891.

If you want to use the background proxy method instead of always backgrounding foo (i.e. Thing.background.foo) you can just leave out the always_background call altogether.

Link: Chapter 8. TorqueBox Messaging via torquebox.org