>>is there anyway to "spawn" another process, so it wont affect any users??
>>

To spawn another process, you might try <cfhttp..> in the code that
'discovers' the application structure is full enough and needs to be written
to the database. If CF has enough free threads, both processes (the original
user process and the new bulk insert process) will run. The user that
'discovers' the structure is full enough is penalized a 1-second 'timeout'
penalty with the <cfhttp> call. If CF doesn't have enough free threads at
the time, the user will be suspended.
<cfif ... GE 100>
<!--- This 'post' activates BulkInsert.cfm. We dont receive any data back
from that page. --->
<cfhttp timeout="1" url="#webroot#BulkInsert.cfm" method="post">
        <cfhttpparam name="whatever" type="url/form/etc" value="#as needed#">
</cfhttp>
</cfif>

The BulkInsert.cfm target page fetches the original app structure, resets
the original structure empty, and then writes that data to the database:
        <cfapplication name="sameAppName sessionmanagement="no"
setclientcookies="no" clientmanagement="no">
        <cflock scope="application" ... type="exclusive">
                <!--- Fetch all the data needing to be written --->
                <cfset localCopy=duplicate(application.original_application_structure)>
                <!--- reset the original application structure empty --->
                <cfset application.original_application_structure=structnew()>
        </cflock>
<!--- Loop to run the DBInsert code. --->
..
..
<!--- When finished, just exit. This template never returns any HTML to a
browser. --->


Error checking. You probably should also track the calls to the bulk insert
template with an application variable, too, so in case it doesn't respond in
a timely manner (or at all), you don't immediately <cfhttp..> call the
bulkInsert.cfm template again from the main app. The BulkInsert template
would decrement that 'application.OutstandingBulkInsertCalls' counter.

Regards

David Perkins



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to