Establish Connection on application startup

Hello everyone,

I want to integrate status messages over xmpp in my Rails application.
My problem is, what I do not want to establish a connection to the
jabber server each time a message is sent and disconnect the
connection afterwards. So I am looking for a solution to establish the
connection on startup and to use this connection in my controllers,
when I need it. I am going to use xmpp4r, xmpp4r-simple or jabber4r to
communicate with the jabber network.

I know, that I have to integrate the initialisation of the connection
in the enviroment.rb, but how can I use the connection im my
controllers? Should i implementate it through the singelton pattern?

I also know, that there are some issues about multiple application
instances (because of FastCGI, Mongrel, etc.), but I do not think,
that it will be a problem, because there will be no race conditions or
something like that.

Or would it be a better solution to establish the connection in an
application outside of rails and make rails to communicate to ist over
distributed ruby. Are there any performance issues with using DRb?

With best regards

Alexander