i trying run 3 threads of http request in coldfusion. email system select 3 different campaigns , send there respective recipients @ same time.
but following code runs 1 thread , drops off.
<cfscript> newslettercampaigngateway = createobject("component", "legacy.ssl.admin.news.model.newslettercampaigngateway"); newsletterlist = newslettercampaigngateway.getnewslettersdueforsend(); //writedump(newsletterlist);abort; </cfscript> <cfloop query="newsletterlist" > <cfset newsletterid = newsletterlist.newsletterid> <cfset campid = newsletterlist.id> <cfset fromemail = newsletterlist.fromemail> <!--- <cfdump var="#campid#"> ---> <cfthread action="run" name="runcampaign#campid#" > <cflock name="runcampaign_#campid#_lock" type="exclusive" timeout="60"> <!--- <cfdump var="#campid#"> ---> <cfscript> httpservice = new http(); httpservice.setmethod("get"); httpservice.setcharset("utf-8"); httpservice.seturl("http://mysamplesite.com/legacy/ssl/admin/news/model/newslettercampaign.cfc"); httpservice.addparam(type="url",name="method",value="sendcampaignnewsletters"); httpservice.addparam(type="url",name="live",value="true"); httpservice.addparam(type="url",name="campaignid",value="#campid#"); httpservice.addparam(type="url",name="newsletterid",value="#newsletterid#"); httpservice.addparam(type="url",name="fromemail",value="#fromemail#"); httpservice.send(); </cfscript> </cflock> </cfthread> </cfloop> <cfloop query="newsletterlist" > <cfthread action="join" name="runcampaign#campid#" /> </cfloop>
any idea guys?
well, decided not use cfhttp , used threading , works.
<cfsetting requesttimeout="300000"> <cfscript> newslettercampaigngateway = createobject("component", "path.to.cfc"); newsletterlist = newslettercampaigngateway.getnewslettersdueforsend(); </cfscript> <cfloop query="newsletterlist" > <cftry> <cfthread action="run" name="runcampaign#url.campaignid#" > <cfset sendrequest(url)> </cfthread> <cfcatch> <cfdump var="#cfcatch#"><cfabort> </cfcatch> </cftry> </cfloop> <cffunction name="sendrequest"> <cfargument name="urlstu" required="true"> <cfset newslettercampaign = createobject("component", "path.to.cfc")> <cfset newslettercampaign.sendcampaignnewsletters(arguments.urlstu)> </cffunction>
Comments
Post a Comment