Brett Payne-Rhodes wrote:
Hi Robin,
That's an interesting suggestion... In trying to get my head around this I've got a couple of questions...
If this is accessed as a custom tag then I'll need to add the webroot to the custom tag directories, yes? Is that a good thing?
It's really only the elseif bit that needs to be under the webroot, so you could split that into a separate file - that said it's easier to deploy as a single tag. If you added the webroot to the custom tag path It's not such a problem - the thing I object to is putting tags, cfcs etc under the webroot when they don't need to be there, in this special case the tag needs to be there. A malicious user couldn't learn much about the site even if they read the code.
The implication I take away from this is that the cfhttp call will 'return' without waiting for the cfinvoke call to complete. Is that the case? And if so then why will it do that?
Oops - I forget to set timeout="0" so that cfhttp returned without waiting - can't remember if that throws an error or not, if it does just catch and ignore it.
Thanks for taking the time, and to everyone else who chipped in.
Let us know if you get it working - could be very handy. Could also mod it to work with cfmodule instead of cfinvoke. Bonus points if you can work out a way of getting this to work like the Unix fork() call!
Robin http://www.rocketboots.com.au
Brett B)
Robin Hilliard wrote:
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/
