For an external server, you *should* be able to configure it as normal:
<cfset hosts = [{serverName='IP.For.Mongo.HQ.Server', serverPort=
port.for.mongo.hq.server]>
<cfset mongoConfig = createObject('component',
'cfmongodb.core.MongoConfig').init( hosts = hosts, dbname='whatever',
mongoFactory=javaloaderFactory );
<cfset mongo = createObject(..).init(mongoConfig);
and then authenticate:
authResult = mongo.authenticate('yourusername', 'yourpassword');
IF that doesn't work for you, please let me knwo what errors you
receive. cfdump authresult to find out what mongodb has to say.
As for whether to use javaloader vs. putting the jars in the
classpath, I'm afraid the best answer is: "try it out and see which is
faster/better for you".
I can tell you that I run javaloader in production, though I'm not
running Twitter type loads. In addition, I built the "get object" part
of CFMongoDB to be optimized for use with javaloader, such that it
should be nearly as fast to use javaloader in typical situations.
Fortunately, it's easy to try: put the mongodb and cfmongodb jars in
your CF classpath, restart, and change your wirebox config to NOT use
the javaloader factory. Basically, just remove the MongoFactory from
your map, and map the mongoconfig like so:
map("mongoConfig")
.to("cfmongodb.core.MongoConfig")
.initArg(name="dbName",value="mongorocks")
.initArg(hosts=[.....])
.asSingleton();
Marc
> --
> You received this message because you are subscribed to the Google Groups "CFMongoDB" group.
> To post to this group, send email to cfmo...@googlegroups.com.
> To unsubscribe from this group, send email to cfmongodb+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cfmongodb?hl=en.
>
>
One other thigh to add to what Marc said, make sure to double check any firewalls you have setup to make sure you aren't getting shutdown there.
I'm no wirebox expert, but I don't think you would call it from your
mapping file, but instead you'd call it after wirebox does its config.
Something like:
<cfset binder = createObject("component", "Binder")>
<cfset application.injector =
createObject("component","coldbox.system.ioc.Injector").init("Binder")>
<cfset mongo = application.injector.getInstance("mongo")>
<cfset mongo.authenticate(username, password)>
Presumably at that point, you could get the username and password from
your coldbox config file.
Marc
map("mongoFactory")
.to("model.utilities.cfmongodb.core.JavaloaderFactory")
.asSingleton();
//use cfmongodb.core.DefaultFactory to load mongodb jars in your CF classpath
map("mongoConfig")
.to("model.utilities.cfmongodb.core.MongoConfig")
.initArg(name="dbName",value="mongorocks")
.initArg(name="mongoFactory", ref="mongoFactory")
.asSingleton();
map("mongo")
.to("model.utilities.cfmongodb.core.Mongo").
initArg(name="mongoConfig", ref='mongoConfig')
.asSingleton();
}
I'm struggling to understand your mongo config, can you clarify?
map("mongoConfig")
.to("model.utilities.cfmongodb.core.MongoConfig")
.initArg(name="dbName",ref="mongoDBSetting")
.initArg(name="mongoFactory", ref="mongoFactory")
.initArg(name="hosts", ref="mongoDBHost")
.asSingleton();
Questions:
1. What does ref="mongoDBSetting" refer to? A setting in ColdBox Config?
2. What does the last initArgs for mongoDBHost do?
I'm not 100% familiar with Wirebox, so I'm going to read through the docs again.
Essentially I'm looking to build a config to leverage CB's environment settings and have wirebox map mongo to my local db when running in development, and a remote hosted mongodb when in the production environment.
Thanks for your assistance.
Nolan
Thanks.
You did figure out how to close the connection, right? Absolutely you
should not be closing connections on each request, but only on
application stop (or restart)!
Marc
> --
> You received this message because you are subscribed to the Google Groups
> "CFMongoDB" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cfmongodb/-/9UGNp1hUv2EJ.