标签: cfthread

使用cfthread join获取在cfloop中运行的变量的值

感谢回复!!但我仍然无法做到这一点.我得到的错误是"类型objGet1在类型类coldfusion.runtime.VariableScope类型的Java对象中未定义."

以下是我的完整代码.我只想转储包含cfhttp信息的每个线程的值.

http://www.google.com/search?"&"q = Vin + Diesel"&"&num = 10"&"&start =")/>

<cfset intStartTime = GetTickCount() />

<cfloop index="intGet" from="1" to="10" step="1">

    <!--- Start a new thread for this CFHttp call. --->
    <cfthread action="run" name="objGet#intGet#">

        <cfhttp method="GET" url="#strBaseURL##((intGet - 1) * 10)#" useragent="#CGI.http_user_agent#" result="THREAD.Get#intGet#" />

    </cfthread>

</cfloop>

<cfloop index="intGet" from="1" to="10" step="1">

    <cfthread action="join" name="objGet#intGet#" />
    <cfdump var="#Variables['objGet'&intGet]#"><br />

</cfloop>
Run Code Online (Sandbox Code Playgroud)

当我在循环中加入线程后使用.我得到了预期的结果谢谢!!

coldfusion cfthread cfloop

5
推荐指数
1
解决办法
2071
查看次数

在 Coldfusion 线程中使用函数参数

如何在 Coldfusion 线程中使用函数参数?我不明白为什么会出现以下错误:

元素 SOMEID 在 ARGUMENTS 中未定义。

我的代码的简化示例。

public any function createSomeEntity(required numeric someId) {     
    thread action="run" name="someThread" {
        var result = someFunction(someId = arguments.someId);
        // some logic
    }
    thread action="join" name="someThread" timeout="5000";
    
    if (someThread.status != "COMPLETED") {
        // action 1
    } else {
        // action 2
    }
}       
Run Code Online (Sandbox Code Playgroud)

coldfusion multithreading cfthread

4
推荐指数
1
解决办法
46
查看次数

Coldfusion (railo) 和 cfthread 没有按我的预期工作

我以前没有使用过 cfthread,但我使用以下代码但它不起作用。

<cfloop from="1" to="5" index="local.pageNo">

            <cfthread name="thr#local.pageNo#" threadIndex="#local.pageNo#" action="run">

                <cfif local.pageNo GT 1>
                    <cfhttp url="#local.apiURL#&page=#local.pageNo#" method="get" result="local.myResults" >
                    </cfhttp>
                    <cfset local.myResponse = deserializejson(local.myResults.filecontent)>
                </cfif>

                <cfloop from="1" to="#arrayLen(local.myResponse.result)#" index="i">
                    <cfset local.apartmentList = listAppend(local.apartmentList,local.myResponse.result[i].id & '-0')>
                </cfloop>

            </cfthread>

        </cfloop>

        <cfthread action="join" name="thr1,thr2,thr3,thr4,thr5"/>
Run Code Online (Sandbox Code Playgroud)

我期望 local.apartmentList 是一个很大的 ID 列表,但它返回空。这几乎就像线程内的代码被跳过一样。有人能发现我做错了什么吗?

coldfusion railo cfthread

2
推荐指数
1
解决办法
502
查看次数

Lucee/Adobe ColdFusion - 从线程设置/获取信息{}

我正在创建一个简单的电子邮件服务器状态页面,该页面调用两个不同的 CFC。

状态页要求:

  1. 通过 CFC 查询 MariaDB 数据库表并从两个字段返回数据:server_name(即 MyServerName)和 server_domain(即 mail.domain.com)。目前,数据库表中有 4 行需要提取。
  2. 将步骤 1 中的数据库数据传递给 CFC,检查端口 25 是否正在侦听。如果 CFC 可以到达端口 25,则结果为 true,否则结果为 false。这一步需要进行线程化。
  3. 将步骤 2 中的布尔结果传递给循环以打印 server_name 和布尔结果。

输出类似于以下内容:
MyServerName - <up arrow>
MyServerName2 - <up arrow>
MyServerName3 - <up arrow>
MyServerName4 -<down arrow>

代码:

    RetrieveEmailServers = APPLICATION.selectQueries.RetrieveEmailServers()
    if (RetrieveEmailServers.recordCount) {
        for(i = 1; i <= RetrieveEmailServers.recordCount(); i++) {
            LOCAL.theDomains = RetrieveEmailServers.check_servers_domain[i];
            LOCAL.theNames = RetrieveEmailServers.check_servers_name[i];
            thread action="run" name="thread#i#" theDomains="#LOCAL.theDomains#" theNames="#LOCAL.theNames#" {
                VARIABLES.theServers = APPLICATION.emailCheck.checkSMTPServer('#domains#',25,'','');
            }
        }
        thread action="join" …
Run Code Online (Sandbox Code Playgroud)

coldfusion cfthread cfloop lucee

2
推荐指数
1
解决办法
291
查看次数

ColdFusion - CFThread设置标头失败?

我从CFThread得到了一个奇怪的错误.我把它包裹在一个在CFThread之外运行完美的函数.但是,它需要大约20秒才能完成,因此我将其拍摄到CFThread,然后将用户CFLocation到新页面并在完成后提醒他们.

它还包含在CFTRY中,如果出现问题,请给我发电子邮件.

我收到CFCATCH.Message所在的电子邮件:

"由于请求已经完成,CFThread无法将标头设置为响应"

我在Google上找不到任何类似错误的引用.我假设它不喜欢我在调用Thread后直接使用CFLocation的事实.所以,对于它的地狱,我尝试使用META REFRESH重定向用户.相同的错误结果.

有任何想法吗?

2013年7月8日更新:

代码在这里:

<cfset admsID = replace(createUUID(),"-","","all")>
<cfthread action="run" name="runADMS#admsID#" admsID="#admsID#" formstruct="#form#">
<cftry> 
<cfobject component="cfc.AutoDealerBrandMarketShare" name="adms">
<cfset rptPDF = adms.buildReport(dealer=formstruct.chosenDealer,mkt=formstruct.DMACode,make=formstruct.Make,rptID=admsID)>
<cfcatch type="any">
<cfmail to="pmascari@mysite.com" from="techsupport@mysite.com" subject="ADMS Error">
Error occurred running a Polk Auto Dealer Market Share report.
#cfcatch.Message#
#cfcatch.detail#
</cfmail>
</cfcatch>
</cftry>
</cfthread> 
<cflocation url="http://www.usercanwaithere.com">
Run Code Online (Sandbox Code Playgroud)

coldfusion header response cfthread

0
推荐指数
1
解决办法
284
查看次数

标签 统计

cfthread ×5

coldfusion ×5

cfloop ×2

header ×1

lucee ×1

multithreading ×1

railo ×1

response ×1