Forum: Ruby on Rails Establish Connection on application startup

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dcbce8ec34ce9bb6454e4a03543c3ec1?d=identicon&s=25 (Guest)
on 2007-02-15 17:16
(Received via mailing list)
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

This topic is locked and can not be replied to.