issues with switching databases, mongoconfig.configureEnvironment()

15 views
Skip to first unread message

chong kahshiu

unread,
Sep 2, 2014, 1:03:29 PM9/2/14
to cfmo...@googlegroups.com
Hi. Im currently working with two DB's in mongo, login database and other databases. However, my Railo setting ties to only one application.cfc. From the geting started example, I got to know we only create one instance of mongoclient in application.cfc. Now switching database will mean running configure environment on each request, right (since it provides  hook to change DBname)? If yes, will this cause issues when two simutaneous requests config diff database pointed to, resulting in wrong operations ran on wrong database? Else, is there another way to switch database?

Also, on another note, I was observing the # of connections made to mongo from console. instantiating mongoclient creates 2 connections. when close() only one connection killed, leaving the other out... is this normal? It ends up accumulating connections on every applicationend

Marc Esher

unread,
Sep 6, 2014, 8:29:02 AM9/6/14
to cfmo...@googlegroups.com
Unfortunately, I can't think of a way right now that cfmongodb would easily support two databases on a single mongoclient object. It's a weakness, for sure, but it's require some refactoring to support.

You could certainly create two separate mongoclients, however.

The connection behavior is interesting... can you determine exactly what object is still holding on to a connection? A tool like VisualVM would help here.


On Tue, Sep 2, 2014 at 1:03 PM, chong kahshiu <kah...@gmail.com> wrote:
Hi. Im currently working with two DB's in mongo, login database and other databases. However, my Railo setting ties to only one application.cfc. From the geting started example, I got to know we only create one instance of mongoclient in application.cfc. Now switching database will mean running configure environment on each request, right (since it provides  hook to change DBname)? If yes, will this cause issues when two simutaneous requests config diff database pointed to, resulting in wrong operations ran on wrong database? Else, is there another way to switch database?

Also, on another note, I was observing the # of connections made to mongo from console. instantiating mongoclient creates 2 connections. when close() only one connection killed, leaving the other out... is this normal? It ends up accumulating connections on every applicationend

--
You received this message because you are subscribed to the Google Groups "CFMongoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfmongodb+...@googlegroups.com.
To post to this group, send email to cfmo...@googlegroups.com.
Visit this group at http://groups.google.com/group/cfmongodb.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages