Beruflich Dokumente
Kultur Dokumente
<!--- obviously, you might have this coming from somewhere different --->
<cfset local.ds = "theDatasource">
<!--- This is the number of threads that you want to run at a time. We callt
he collection of threads a Spool.
This doesn't change any JRun or JVM settings, so be aware of
that. In other
words, if you have JVM setting that specifies a max of 10 threads
and you set the maxConcurrentThreads variable to 11 then only 10 will be
created to start with, there will then be a wait until the next
single thread is created --->
<cfset local.maxConcurrentThreads = 5>
<!--- This is the max number of records from your data query that will be
processed inside each thread. Think of it as the control
on how long you want each thread to run for. For a record set of
26471, I used a batch size of 200 with 5 concurrent threads --->
<cfset local.recordBatchSize = 200>
<!--- depends very much on the size of your record set and how much
processing you are going to do --->
<cfsetting requesttimeout="360">
<cfsavecontent variable="local.result.output">
<cfquery datasource="#local.ds#" name="local.data"
maxrows="#local.maxRecordsetSize#">
select fields
from tableName
</cfquery>
<cfoutput><h1>#local.data.recordCount# records to
update</h1></cfoutput>
<cftry>
<!--- Weird way of getting thread value out,
but the trouble is threads are NOT structures. If anyone
has a better way of doing this,
please let me know!--->
<cfset local.theThreadTotal =
Evaluate('#local.theThreadName#.recordTotal')>
<cfset local.threadRecordTotal =
local.threadRecordTotal + local.theThreadTotal>
<cfcatch type="any">
<cftry>
<cfdump var="#cfcatch#">
<cfdump
var="#Evaluate('#local.theThreadName#')#">
<cfcatch type="any">
<cfoutput><p>Unrecoverable
error on thread #local.theThreadName#</p></cfoutput>
</cfcatch>
</cftry>
</cfcatch>
</cftry>
</cfloop>
<cfreturn local.result>
</cffunction>