G'day all: thanks everyone for replying.
I finally had a chance to get back to this, and have looked at each
response. I'll reply to all of them in one post to minimise clutter.
wikiwikiman:
Just make sure that you don't recreate a ReactorFactory at each request,
but continue to use the same object instance...
Right. Didn't know that, but makes sense. And indeed I *was* recreating
each request. So this would not have helped matters :-)
I've refactored the code so it's only be created the once (and have verified
this by sticking some <cflog> calls in the pseudo-constructor and init()
method of reactorFactory.cfc: it's only being called once for the life of
the app (well: actually twice, but I'm putting that down to some
bootstrapping stuff. It's certainly not being recreated by any of my own
code).
This was not the problem.
Doug:
Did you use the reactor configuration that comes with MG's CS.xml? Or did
you provide your own?
I found another hiccough here. I'm still trying to work out how all this
comes together, so was changing the MODE setting in reactor.xml. Your
comment encouraged me to check what was going on in ColdSpring.xml, and
spotted it being set to "development" there. I changed it to "production".
I'm not using the default suggested ColdSpring.xml config (the commented out
bit in ColdSpring.xml: "ORM Framework Configuration"), as the ormService
kept failing. I added in a couple of constructor args it seemed to need.
So instead of simply this:
<alias alias="ormService" name="ormService.Reactor" />
I have this:
<bean id="ormService" class="reactor.reactorFactory">
<constructor-arg name="configuration"><ref bean="reactorConfiguration"
/></constructor-arg>
<constructor-arg
name="pathToConfigXml"><value>/config/reactor/Reactor.xml</value></constructor-arg>
</bean>
This stopped the ormService complaining about not having those settings, but
I'm not sure if that's the correct way of doing it. It might be treating a
symptom, rather than the problem.
I have put a log call in all the methods of reactorFactory.cfc, thus:
<cflog file="reactorFactory" type="information" text="[methodname] mode:
#variables.objectFactory.getConfig().getMode()#">
All report "production". That said, wouldn't I be seeing the schema being
queried EVERY TIME if I was in dev mode? Not just "quite often"?
Ali:
Sorry, I didn't have time to investigate your response (I've a 30min commute
on the train, so had to squeeze my investigations into that...), but it does
seem like your situation might contribute; I am calling validate() in a few
places. However I'm also seeing what I'm seeing on vanilla read actions,
and I'm pretty sure I'm not being so anal as to validate() stuff coming
*out* of the DB (although I have not checked).
Bottom line:
I'm still seeing the table schema being queried 30% of the time (this is an
improvement). 30% is based on sitting on one URL and refreshing it a couple
of dozen times, and tallying up the query activity.
Thanks again for everyone's attempted help so far.
I'm certain I'm doing something daft, but haven't had time to pare back my
test code to investigate sensibly. Please don't anyone spend too much time
scratching their heads over this on my behalf, given I'm not spending too
much time on it myself.
Cheers again.
--
Adam
--------------------------------------------------
From: "Ali Syed" <[EMAIL PROTECTED]>
Sent: Tuesday, April 22, 2008 4:17 PM
To: <[email protected]>
Subject: Re: [Reactor for CF] Reactor querying the DB schema for every query
(reposting in correct place this time, hopefully :-)
I had the same experience while working with MG Unity and Reactor. The
database schema was being queried every time I did an insert or an update
even though everything was set to production. So to narrow things down I
took MG out of the equation and wrote a simple test just with reactor. It
seems like if you validate the record using the validate() method before
you do the insert or update the DB schema is queried otherwise its not. I
am using Reactor version 429 with coldfusion MX7 and SQL Server 2005.
After a lot of looking around I tracked this down to line 186 of
reactor.core.objectFactory
<cfset var dictionaryXmlPath =
"#getObject(arguments.alias).getMapping()#/Dictionary/#arguments.alias#dictionary.xml"
/>
The call to getObject seems to generate the query to the database schema
I changed the above line to the following
<cfset var tempmapping = "/" & Replace(getMapping(), ".", "/", "all") />
<cfset var dictionaryXmlPath =
"#tempmapping#/Dictionary/#arguments.alias#dictionary.xml" />
and that seems to have solved the issue. I am no where near a Reactor
expert. I have used it for a couple of months so I wanted to share this
with everyone so that they can take a look and see what they think about
this.
The test code I used is as follows.
<cfsilent>
<cfapplication name="testapp" sessionmanagement="true"/>
<cfif not structKeyExists(application,'reactor') or isDefined("url.init")>
<cfset application.reactor = CreateObject("Component",
"reactor.reactorFactory").init(expandPath("reactor.xml")) />
</cfif>
</cfsilent>
My reactor configuration file is as follows
<reactor>
<config>
<project value="testapp" />
<dsn value="testdsn" />
<type value="mssql" />
<mapping value="/testapp/data" />
<mode value="production" />
</config>
<objects>
<object name="Post">
<hasMany name="Comment">
<relate from="PostId" to="PostId" />
</hasMany>
</object>
</objects>
</reactor>
And finally the code that I am using to test this
<cfset record = application.reactor.createRecord("Post")>
<cfset record.setPost("Post is going to be the post text ")>
<cfset record.setTitle("This is the post title")>
<!--if you remove validate database schema is not queried-->
<cfset record.validate()>
<cfset record.save()>
Ali
"Doug Hughes" <[EMAIL PROTECTED]> 4/22/2008 8:46 AM >>>
Did you use the reactor configuration that comes with MG's CS.xml? Or did
you provide your own?
Also - I've had embarasing experiances where the application itself was
reloading.... someone decided to clear the application scope in the
application.cfm for testing purposes and then checked that code in to our
repo.... thus the application was always reloading. I'd check to make
sure
that's not the case.
But, it does sound to me like reactor is in development mode (even if
model-glue is in production).
Doug
On Tue, Apr 22, 2008 at 8:54 AM, Adam Cameron <[EMAIL PROTECTED]>
wrote:
To me it sounds like MG is set to reload on each request. You want MG
not
> to reload or rescaffold and you want reactor in production mode.
>
Hi Doug.
I have this in my ColdSpring.xml file:
{code}
<property name="reload"><value>false</value></property>
<!-- Rescaffold is overridden by reload - if reload is false,
rescaffold's
setting doesn't matter -->
<property name="rescaffold"><value>false</value></property>
{code}
There's nothing either way specifically in ModelGlue.xml (my
understanding
being that this responsibility is taken over by ColdSpring.xml in the
latest
version of M-G).
One variation from the installation guidelines I have is that my /reactor
mapping is not set in CF, but is done in Application.cfc. And I have the
mapping because I've got the reactor dir in a different dir:
[base]/com/alagad/Reactor (the CF and site webroot are
[base]/PhotoGallery;
I'm using the inbuilt web server for this). Could this be an issue? I
would expect if there was any problems with said approach I'd be getting
far
more serious issues than what I'm seeing (ie: I'd expect it not to work
at
all), so presume it's OK.
As per previous, I reckon people shouldn't spend too much time on this @
present as I'll set up some test rigs this evening in a more controlled
environment, and have a mess around. I might be able to sort it out
myself.
That said, I do appreciate the suggestions: I'd just hate for you lot to
be spending more time on this than I can, at present. If you know what I
mean.
Cheers.
--
Adam
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
--
Doug Hughes, President
Alagad Inc.
[EMAIL PROTECTED]
888 Alagad4 (x3)
Office: 919-550-0755
Fax: 888-248-7836
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
--- Scanned by eMail Protection Services---
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --