I have about 50 scheduled tasks that run every 10 ...
# cfml-general
p
I have about 50 scheduled tasks that run every 10 minutes. They check to see if there's any new data that needs to be imported. If the date/time stamp has changed on a corresponding text file, then 1 of the 50 programs will processes it. 50 customers, 50 different text files with their own business rules. I'd like for all 50 to be run 1 at a time, just in case something goes wrong - just being careful that they don't conflict with each other. What I did was chain them together so that when ABC is finished, then BCD runs next. But my boss doesn't like my solution, so now he's asking me to come up with an alternative way of accomplishing the same thing. I just don't want them to all run at the same time.
m
What was the reason why your solution wasn't accepted?
☝️ 1
p
He just thinks it's a brittle solution.
m
I have some functionality that has some similarities. What I did was a scheduled task that kicked off at a regular interval. It looked for activity to process. In your case, it would look to see what the next date/time stamp file needs processing. At the end of that processing, you could look to see if there is more work left to do. If so, immediate call itself. You'd have to add some intelligence to ensure you don't overrun into the next scheduled time frame. But otherwise, your single task would essentially keep running until each file is processed.
p
Yes, that's almost the same thing. Each of the 50 programs have all kinds of complications with the customers' business rules so I really don't want to put them all together. Hmmmm.... Maybe make each one a function.... I don't know though.
m
In my case, I am parsing lots of different inbound emails and handling them according to whatever business rules we have per email. Maybe 50ish different business rules. That's all one scheduled task, but obviously inside of the scheduled task itself, we have conditional code that calls whatever function that particular email calls for.
p
That gives me something to think about. I'll give it a try with our next customer.
g
just shooting from the hip... How about using something async or thready?
p
If your on AWS consider looking at https://aws.amazon.com/step-functions/ which is an orchestration engine for workflows.
👍🏼 1
q
Honestly, if it's more than a handful of tasks, I don't know if I trust ACF/Lucee task scheduler, esp if there are dependent tasks that need to run after. At my org, we use a tool called UC4 which can call Java classes (or CF URls), and do reporting on success/failure and make sure batches don't run concurrently.
s
I have used a thread controller to throttle tasks. In my case, the single scheduled task would keep 6 threads (configurable) running at the same time. Each thread would save its progress while running so if it threw an exception and prematurely terminated, the next scheduled run would pick up where it left off. Make sure you log and notify upon exceptions so you know something may need attention.
p
Yeah, we have a scoreboard that lights up if a task doesn't run to completion. A thread controller is another great idea. Thanks!