Brett Payne-Rhodes wrote:

Happy New Year to you all!

Does anyone have a simple mechanism for queueing/delaying tasks for later execution?

The scenario is that the user will request a task to be executed but that task will be long running and I want it to happen seperately to the users session. If I have to I can probably create and delete one-off tasks in the CF task scheduler (anyone have a code snippet for that?) but I was hoping there was a simpler way...

Brett I haven't tried this out but something like this could work. Create asyncinvoke.cfm under your webroot:


<cfif isdefined("attributes") and thisTag.executionMode eq "start">

        <!---
                We have been called as a custom tag, save the
                attributes in a unique location
        --->
        <cfset uuid = createUUID()>
        <cfset server["asyncinvoke" & uuid] = attributes>

        <!---
                ...and create a separate request to make the call
        --->
        <cfhttp method="get"
        url="http://127.0.0.1/asyncinvoke.cfm?attributeskey=#uuid#";>

<cfelseif cgi.REMOTE_ADDR eq "127.0.0.1" and
structKeyExists(url, "attributeskey")>

        <!---
                We have been called via HTTP request from the
                custom tag, get the attributes
        --->
        <cfset attributes = server["asyncinvoke" & url.attributeskey]>
        <cfset structDelete(server, "asyncinvoke" & url.attributeskey)>

        <!--- And make the original call --->
        <cfinvoke argumentcollection=#attributes#>

</cfif>

You'll need to tweak the cfinvoke. You could use this tag in place of cfinvoke to have the cfc method execute in a separate request.

---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to