Coldfusion中的异步HTTP请求

Coldfusion中的异步HTTP请求,coldfusion,coldfusion-10,cfhttp,cfthread,Coldfusion,Coldfusion 10,Cfhttp,Cfthread,如何使用CFHTTP标记执行异步HTTP请求 我正在循环查询结果,并通过HTTP post将一些数据发送到URL。 查询中有很多记录,因此cfhttp需要很多时间 是否可以在ColdFusion中发送异步HTTP请求? 有人建议我可以创建一个线程并在其中调用cfhttp。 除了cfthread还有其他方法吗?正如@peter boughton所建议的,使用线程 在CF 9.0.1中,线程中存在http错误 这是我做的一个快速原型: //cf\u吸吮\u变通方法.cfc component

如何使用CFHTTP标记执行异步HTTP请求

我正在循环查询结果,并通过HTTP post将一些数据发送到URL。 查询中有很多记录,因此cfhttp需要很多时间

是否可以在ColdFusion中发送异步HTTP请求? 有人建议我可以创建一个线程并在其中调用cfhttp。
除了cfthread还有其他方法吗?

正如@peter boughton所建议的,使用线程

在CF 9.0.1中,线程中存在http错误

这是我做的一个快速原型:

//cf\u吸吮\u变通方法.cfc
component extends=“com.adobe.coldfusion.base”{
公共函数cacheScriptObjects(){
local.tags=[“CFFTP”、“CFHTTP”、“CFMAIL”、“CFPDF”、“CFQUERY”,
“CFPOP”、“CFIMAP”、“CFFEED”、“CFLDAP”];
for(local.tags中的local.tag){
GetSupportedTagAttribute(local.tag);
}
}
}
//异步\u http.cfm
lg(“开始”);
main();
lg(“完成”);
空函数main(){
CreateObject('component','cf_sucks_workaround')。cacheScriptObjects();
startThreads();
}
void函数lg(必需字符串txt){
WriteLog(file='threads',text=“t#threadNum()###arguments.txt#”);
}
void函数sendRequest(){
var httpService=newhttp(timeout=“3”,url=”https://www.google.com");
lg(“发送http请求”);
var httpResult=httpService.send().getPrefix();
lg(httpResult.StatusCode);
}
void函数startThreads(){
对于(local.i=1;i LTE 3;i++){
thread action=“run”name=“thread#i#”appname=“derp”i=“#i#”{
lg(“启动”);
sendRequest();
lg(“结束”);
}
}
}
数值函数threadNum(){
return(IsDefined('attributes')和StructKeyExists(attributes,'i'))?attributes.i:0;
}
生成日志输出:

t0 start
t0 done
t1 start
t2 start
t3 start
t3 send http req.
t1 send http req.
t2 send http req.
t3 200 OK
t3 end
t1 200 OK
t1 end
t2 200 OK
t2 end

为什么要使用cfthread以外的方法?是否需要等待每个cfhttp调用完成?或者您只关心它们是否都已发送。您是否尝试过
?我想等待所有http调用是否完成?peter,因为我使用的是CF的标准版本,该版本中的线程有soem限制。