So tonight I built cron in CFML. Again. Because it's missing from both the language framework and every runtime. Am I the only one who constantly fights this battle? In the past four years I've built four distinct cron implementations in CFML and it's completely retarded.
The JRE provides TimerTask, but it's a huge pain in the ass to use with CFML because the Java-to-CFML bridges are laughably weak. OpenSymphony has Quartz (which is awesome), but being Java, it suffers the same problem. Yes, even with the bennies CFGroovy offers in the Java space.
CFSCHEDULE is lame, especially on ColdFusion with it's 61 second frequency limit. Even with an optimal implementation the entire mechanism is flawed because it's a) stuck with equal iteration periods, and b) can only invoke URLs. Every distinct task requires punching a hole in your URL security, making a UI-layer facade for the task, etc.
The Java mechinisms are much better because they stay in-JVM (i.e., don't go through HTTP), but the statelessness of CFCProxy is a huge burden. You can't access already-instantiated CFCs, which means you end up writing a massive pile of custom facade/proxy code to interface with your already-running business model.
The natural solution, of course, is implementing cron in CFML. It allows you to pay either the HTTP or CFCProxy cost exactly once, as well as have cron's incredibly flexible scheduling format. This fact, in it's various manifestations, drives me to drink rather ridiculous amounts.
The flip side, of course, is the dynamic reloading nature that CFML servers offer. I simply cannot understand why other JVM frameworks have not copied this feature. The complete avoidance of all the JVM restarts and classloading hell is a benefit worth enormous sacrifice. Which, I suppose, is why I write CFML both for my salary and for personal projects.
Am I the only one who thinks this is a problem? With both CFML and other JVM frameworks.
No, you are not the only one.
When I was reading about Grails it sounded like their scheduler was pretty advanced and cron like while allowing you to execute groovy code without an http request. I believe it was all built on top of Quartz or Spring's scheduling services.
Personally I really like that CFML allows you to avoid the compile – reload container – debug cycle. It one reason why I have continue to look into Groovy/Grails as they seem to be attempting to make it more dynamic for reloading your application much like CFML.
There's a cron plugin for OpenBD:
http://wiki.openbluedragon.org/wiki/index.php/Category:CronPlugin
I agree with you, the lack of a good scheduler can be a pain. An admin that I work with rewrote the old scheduler he used (BMC Control-M) as a CF application. Sadly, he should have to rewrite this if there was a good interface for it already.
Are you planning on releasing your new code by any chance?
I have felt this pain for years. You are not alone.
One example, the CFAdmin did not have a pause for scheduled tasks until I bugged and begged for it.
You don't want to use my Dynamic Proxy in Javaloader to ease the Java->CFML bridge?
It would make things a lot easier for you.
Or is there an area in which it can be improved that would help you out?
(Totally agreed that CFCProxy is not that great)
I especially agree with the way you have to punch a hole through your application security. Secret URL keys are messy and feel so … wrong.
The 60 second limit is also ridiculous. The worst thing is it doesn't have to be like this! CF scheduler can handle per-second scheduling – we do it all the time. Right now it requires an XML hack to the neo-cron.xml file. It's obtuse and ugly but it works.
I'd love to know how you handled this task. It's something that I'm struggling with now. :(
After the 9.0.1 update broke scheduled tasks (for us at least – http://stackoverflow.com/questions/3870895/coldfusion-neo-cron-xml-has-been-modified-when-it-hasnt-been) we decided to buy VisualCron, a Windows scheduler that runs on a server as a service and can execute tasks in almost any way possible.
We've found it very stable so far, and it has an API (through .NET admittedly) that can be interrogated for task run stats etc. If people are looking for alternatives I'd recommend it.
I've heard CF X is going to have an update to the scheduled task engine too, so that should be interesting too.
Cheers,
Ciaran