A lot of applications have a middleware layer.  In some ways,
ActiveRecord or Mailer is thought of as a middleware.

But, for example with J2EE, you can run background servers and threads.
 Can this be done with Ruby and how?