xml - ColdFusion 超时错误

标签 xml sql-server-2005 coldfusion timeout

我有一个每天运行一次的计划任务,它构建一个我传递给另一个组的 XML 文件。最近数据量大大增加,现在导致任务超时(我认为)。我试图尽可能地优化我的脚本,但没有成功。它在一个小时之前就超时了,我没有收到任何类型的 ColdFusion 错误。相反,我在运行后收到“无法找到此页面”。

  • 这会不会是 Coldfusion 以外的某个地方的超时?
  • 是否有更有效的方法来构建此 XML 文件?

文件:

<cfsetting requesttimeout="7200">
<cftry>
    <cfquery datasource="datasource" name="getPeople">
        select PersonID, FirstName, LastName
        from People
    </cfquery>
    <cfquery datasource="datasource" name="getDepartments">
        select d.DepartmentID, DepartmentName, pd.PersonID
        from Department d inner join PersonDepartment pd on d.DepartmentID = pd.DepartmentID
    </cfquery>
    <cfquery datasource="datasource" name="getPapers">
        select PaperID, PaperTitle, PaperDescription, pp.PersonID
        from Paper p inner join PersonPaper pp on p.PaperID = pp.PaperID
    </cfquery>
<cfsavecontent variable="theXML"><?xml version="1.0" encoding="utf-8" ?><people>
<cfoutput query="getPeople"><cfsilent>
        <cfquery dbtype="query" name="getPersonDepartments">
        select DepartmentID, DepartmentName
        from getDepartments
        where PersonID = #getPeople.PersonID#
        </cfquery>
        <cfquery dbtype="query" name="getPersonPapers">
        select PaperID, PaperDescription
        from getpapers
        where PersonID = #getPeople.PersonID#
        </cfquery>
        </cfsilent> <person>
        <person_id>
            #getPeople.PersonID#
        </faculty_id>
        <person_first_name>
            #getPeople.Firstname#
        </person_first_name>
        <person_last_name>
            #getPeople.LastName#
        </person_last_name><cfif getPersonDepartments.recordcount gt 0>
        <departments><cfloop query="getPersonDepartments">
            <department>
                <department_id>
                    #getPersonDepartments.DepartmentID#
                </department_id>
                <department_name>
                    #getPersonDepartments.DepartmentName#
                </department_name>
            </department></cfloop>
        </departments></cfif><cfif getPersonPapers.recordcount gt 0>
        <papers><cfloop query="getPersonPapers">
            <paper>
                <paper_id>
                    #getPersonPapers.PaperID#
                </paper_id>
                <paper_description>
                    #getPersonPapers.PaperDescription#
                </paper_description>
            </paper></cfloop>
        </papers></cfif>
    </person>
</cfoutput></faculty>
</cfsavecontent>
<!--- Generate the file that contains the RSS --->
<cffile action="write" file="#application.serverroot#/People.xml" output="#theXml#" nameconflict="overwrite">
<cfcatch>
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>
Done!

最佳答案

对我来说,这听起来像是内存问题。您的页面可能会填满专用于 Coldfusion 的整个堆空间,然后以几兆字节“存在”,这些空间会被垃圾收集器清理直到超时。 我处理了超过 1GB 的 XML 文件,所以在我弄清楚所有问题之前我做了一场噩梦。

那你能做什么?

  1. 确保调试已关闭。

  2. 查看日志

  3. 打开 CF Admin 的 Monitor 工具,看看运行它时会发生什么。 (如果看不到监视器,请使用任务管理器并查看 jrun 占用的内存量是否与 cfadmin 中设置的相同)

  4. 您还可以粗略估计您的 xml 有多大,例如行数除以该 XML 节点中的平均字符数。如果它太大,这可以帮助您找出答案。

查看 Charlie Arehart 的工具列表,这些工具可以帮助您解决这个问题和其他问题 http://www.carehart.org/cf411/

还有其他构建 XML 的方法可以节省内存和/或处理时间。但是,让我们首先找出问题出在哪里。

关于xml - ColdFusion 超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2775445/

相关文章:

java - 冷融合: Regex to match words and replace & change link

coldfusion - 将 ColdFusion 5 基于标签的代码重构为 CFC

php - 使用 PHP simpleXML 提取 XML 数据

xml - XSLT:value-of 返回重复的元素值

sql - 按创建日期列出的所有存储过程?

sql - 更新sql中前100行的随机数?

ms-access - (ColdFusion + Access) 数据库查询错误 "Too few parameters."

c# - 从流中读取 XML

javascript - XSLT 模板不使用参数

sql - 如何通过sql水平显示垂直数据