My team and myself are new to Reactor and we are just playing with ideas at
this moment but this is how we are currently using multiple databases.
(Please note that I am not sure this is a good idea yet.  We have not had
the chance to power test this.)

To accomplish this we are caching Reactor instances on startup using
Application.cfc. This is not how it will be run when we are done though.
The end result is to have each module contain it's own Application.cfc that
extends the primary.  We have just not gotten that far yet so currently this
is all contained within one Application.cfc that is at the root of the
primary folder.
First We set up mappings for reactor itself.

<cfset this.mappings["/reactor"]="c:\wwwroot\Reactor\reactor" />
<cfset 
this.mappings["/ReactorConfigs"]="c:\wwwroot\ApplicationFolder\Extranet\ReactorConfigs"
/>

Second we are setting up mappings to use for the application modules.

<cfset 
this.mappings["/Module1"]="c:\wwwroot\ApplicationFolder\Extranet\Module1\"
/>
<cfset this.mappings
["/Module1Data"]="c:\wwwroot\ApplicationFolder\Extranet\Module1\Data">

<cfset 
this.mallings["/Module2"]="c:\wwwroot\ApplicationFolder\Extranet\Module2\"
/>
<cfset 
this.mappings["/Module2Data"]="c:\wwwroot\ApplicationFolder\Extranet\Module2\Data"
/>

ApplicationFolder is what ever you want it to be and ModuleN would be
whatever we named that module.
Also the /ReactorConfigs mapping I do not believe is needed anymore.....Head
Scratch!  So you can leave that out.  Not sure why we put that in there in
the first place.  (Guess I will have to comment that out and see who yells
at me so I can find out who forgot to document their code.)  Still having
quick access in code to that directory is not a bad idea.  For example if
you wanted to write an module to autobackup your xml's when they change.  I
have already found that with a larger team you need to protech those XML
files.  Our policy here is currently your break it you get to buy the beer.

Below the mappings we are caching the reactor objects like so.

<cffunction name="onApplicationStart" output="false">
    <cfif NOT StructKeyExists(Application, "Module1Reactor")>
      <cfset Application.Module1Reactor = CreateObject("Component", "
reactor.reactorFactory").init(expandPath("/ReactorConfigs/Module1Reactor.xml"))
/>
    </cfif>
    <cfif NOT StructKeyExists(Application, "Module2Reactor")>
       <cfset Application.Module2Reactor = CreateObject("Component", "
reactor.reactorFactory").init(expandPath("/ReactorConfigs/Module2Reactor.xml"))
/>
       </cfif>
</cffunction>

The ReactorConfigs/Module1.xml header looks like this.

<reactor>
 <config>
  <project value="Module1"/>
  <dsn value="Module1"/>
  <type value="mysql"/>
  <mapping value="/Module1Data"/>
  <mode value="development"/>
 </config>

 <objects>

 Your objects go here  :)

 </objects>
</reactor>

Module2's xml would look similar.  It goes without saying that you need a
DSN setup in Coldfusion for each.

(Ummm....But I said it anyway.)

Then you would use it in something like so...

<cfscript>
 var Mod1TableGateway = Application.Module1Reactor.createGateway
("Mod1Table");
 var myAllVar = Mod1TableGateway.getAll();

 var Mod2Record = Application.Module2Reactor.createRecord("Mod2Table");
 Mod2Record.setSomeField(ARGUMENTS.SomeArgument);
</cfscript>

Simple enough but very possibly not wise.  Guess we will find out!  We like
to break things around here anyway as that is an excuse to buy more beer.

We are intentionally testing with a low powered workstation with only 1 gig
of ram.  We have currently 6 databases/modules setup using this method and
are not finding any bottlenecks that were not due to our own stupid
mistakes.  ;)

Hope this is usefull.  Lol!  Let me know if it works for you as we still do
not know if it's a good idea.

(Disclaimer:  If you actually visit Materialflow.com my team is not
responsible for the clutter.  We are new here.  We are here to fix it. Give
us time. ;)


On 10/11/07, Blatz, Ryan <[EMAIL PROTECTED]> wrote:
>
>  Has anyone come up with an easy way to use multiple databases with
> reactor?  Right now the best way I've come up with is to create views that
> go from one database to the other.  This is not ideal (at least in my mind),
> and I am curious to see how other people have handled this.
>
>
>
> Ryan Blatz
>
> System Developer Engineer
>
> Office of Research
>
> The Ohio State University
>
> 1070 Carmack Road
>
> 150 Pressey Hall
>
> Columbus, Oh 43201
>
> 614-688-5931
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- --
> 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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to