多个模板同时运行 [英] Multiple templates running concurrently

查看:95
本文介绍了多个模板同时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经试过使用一个冷灌装模板来运行每10分钟一次。计数器变量在应用程序范围内不幸的是,当模板超时或错误输出计数器不减少。



PS。是否有用于集成应用程序(后端内容)的coldfuison框架

解决方案

使用专用名称 cflock

 < cflock 
timeout =#createTimeSpan(0,0,0,1)#
name =myProcess
throwOnTimeout =no
type =exclusive>
< cfset start = now()>
<!--- CFML要同步。 --->
< cfset interval = 10 * 60> <!--- 10 minutes in seconds --->
< cfif dateDiff(s,start,now())GT interval>
< cfhttp url =yourtemplate.cfm>
< / cfif>
< / cflock>

这确保只有线程运行有问题的代码块。同时访问将在一秒内失败,没有错误。



如果先前超过时间间隔,请确保下一次运行得到启动,跟踪锁内的开始时间,然后在结束时,如果超过时间间隔,让cflock中的最后一个语句是对自身的cfhttp调用。


I have scheduled a coldfusion template to run every 10 minutes how do i prevent it from running when the previous run exceeds 10 minutes.

I've tried using a counter variable in the application scope unfortunately when the template times out or errors out the counter is not decremented.

PS. Is there a coldfuison framework for integrating applications (backend stuff)

解决方案

Use an exclusive named cflock:

<cflock 
    timeout = "#createTimeSpan(0,0,0,1)#"
    name = "myProcess"
    throwOnTimeout = "no"
    type = "exclusive"> 
    <cfset start = now()>
    <!--- CFML to be synchronized. ---> 
    <cfset interval = 10 * 60> <!--- 10 minutes in seconds --->
    <cfif dateDiff("s", start, now()) GT interval>
        <cfhttp url="yourtemplate.cfm">
    </cfif>
</cflock>

This ensures only thread ever runs the block of code in question. Simultaneous access will fail in one second without error.

To ensure the next run gets kicked off if the prior exceeds the time interval, track the start time inside the lock and then at the end, if its exceeded the interval, have the last statement inside the cflock be a cfhttp call to itself.

这篇关于多个模板同时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆