CF India Summit Part Three: All About ColdFusion Scheduled Tasks

December 21, 2018
Host CF Alive podcast, founder CFUnited, CEO TeraTech
Wizard 42 posts
Followers: 13 people
0

CF India Summit Part Three: All About ColdFusion Scheduled Tasks

Host CF Alive podcast, founder CFUnited, CEO TeraTech
Wizard 42 posts
Followers: 13 people
December 21, 2018

Welcome back to the CF India Summit series! This was our last major CF conference for the year, but that doesn’t make it any less relevant. As a matter of fact, there were some of ColdFusion’s sharpest minds in attendance. Here some of our best and brightest gave sessions on many new features of ColdFusion 2018 and QOL talks. Lots of great info that was presented here.

But with all these new updates from Lucee (Check out this MAJOR LUCEE ANNOUNCEMENT!) and Adobe and conferences lately, how is anybody supposed to keep up with regular tasking?

Automation and scheduled tasking of course!

Luckily for us, ColdFusion has quite a few tricks up its sleeve when it comes to scheduled tasks. Here we will talk about the importance of automation and scheduled tasks. Then, we will go over just what ColdFusion, the cfschedule tag, and what Scheduled Tasks can do for you.

“I’m proud to use ColdFusion because it makes me productive. It is a great language. It solves my problems and it solves them more quickly and easily than some of the languages so that’s why I’m proud to use ColdFusion is because how productive it makes me and the modern language that it’s become.” — Brad Wood, Software Architect and Platform Evangelist Ortus Solutions

From CF Alive episode, “029 Design Patterns for amazing app architecture (16 patterns), with Brad Wood

Now, let’s get into the CF side of things.

What exactly are ColdFusion Scheduled Tasks from a developer’s perspective?

CF Scheduled tasks allow you to run any CF template at a specific moment in time. Use scheduled tasks to handily send newsletters, emails, reports, or to just verify data. The possibilities are enormous.

There are two separate types of Scheduled Tasks:

  1. Server Level Tasks
  2. Only tasks that are arranged and scheduled via the ColdFusion Administrator are considered server level tasks.
  3. Application Level Tasks
  4. These tasks are actually written into the ColdFusion app code using the cfscheduler tag. These will show up under the application level tasks section in the administrator.

The former provides a more user friendly experience, whereas the cfschedule tag can be applied with more accuracy.

Using the ColdFusion Administrator

If using the ColdFusion Administrator, you must have the proper permissions in order to use. Check ahead with your server admin prior to starting.

Step 1. Log into the ColdFusion Administrator

Step 2. Scheduled Tasks >> Schedule New Task

Step 3. Enter a Task Name, frequency, and the URL of template to be run.

Step 4. Submit.

That’s pretty much it. The CF Administrator makes life simple. Just be sure to be wary of timeouts. If you believe that your template will run for a long time, be sure to specify a timeout which will override the standard. This will ensure your task actually gets completed to its fullest extent

Using the cfschedule Tag

The cfschedule tag provides a programmatic interface for communicating with the ColdFusion Scheduling Engine. The following is the syntax for the cfschedule tag at its most basic level.

<cfschedule

action = “update”

task = “taskname”

operation = “HTTPRequest”

file = “filename”

path = “path_to_file”

startDate = “date”

startTime = “time”

url = “URL”

port = “port_number”

publish = “Yes” or “No”

endDate = “date”

endTime = “time”

interval = “seconds”

requestTimeOut = “seconds”

username = “username”

password = “password”

proxyServer = “hostname”

proxyPort = “port_number”

proxyUser = “username”

proxyPassword = “password”

resolveURL = “Yes” or “No”>

*As for the update action, this is to create a new task; update may be replaced with runpauseresumeresume allpause alldelete, and list.

Grouping Tasks Together

ColdFusion Scheduled Tasks have received many updates through the different versions. In ColdFusion 10, the grouping of scheduled tasks was added. This is awesome for those of you ready to perform multiple tasks at the exact same interval.

For example, let’s say you wanted to send out a monthly newsletter to your clients, compile monthly report for the boss, and send a maintenance schedule out to your staff all at once. You can schedule these tasks to be completed every month as scheduled. In order to use this feature, just insert this code into the base syntax.

action=update

task=t1 url=”www.adobe.com”

group=”G1″/>

Running Scheduler in Clusters

You can run CF scheduled tasks in cluster. Often it is recommended to do so for redundancy purposes. That way if one server fails, another server can pick up the load and complete the scheduled tasks.

Be aware though that this feature is only available via ColdFusion Enterprise editions.

There are two major caveats you need to remember before setting up clusters.

  1. You must have an empty database (DSN) set up prior to any cluster creation.
  2. When the cluster setting is enabled, YOU MUST HAVE ONLY ONE VERSION OF THE TASK RUNNING. This step is crucial.

Just like before, remember to always check your permissions in order for things to run smoothly. You–for the supplied data source– must be allowed create privileges on the applicable database. Also on the data source, create must be enabled under Allowed SQL on the data source admin page.

Cron Expressions

Cron expressions are compatible with CF Scheduled Tasks. It can come in especially handy when creating a task that runs all throughout the night. Here’s an example straight from Adobe:

For example, if your task needs to execute between 1800–0400 hours on the first of every month, use the expression,

0 0 18–4 1 * ? *

Integration using Quartz Properties

ColdFusion 10 was perhaps the most significant time for change for Scheduled Tasks. And out of all those changes, the prolific may be the ability to utilize the Quartz Job Scheduling Library. This was done to add support for high-precision scheduling of thousands of crucial tasks.

But what is the Quartz Job Scheduling Library?

Quartz is an open source job scheduling library that can be seamlessly integrated into any Java oriented application. (Lucky for us CF’ers huh?)

It can be used to create schedules of varying complexities whose tasks are defined as standard Java components.

This huge contribution was great in ColdFusion 10 and has been carried over to CF2018.

What’s New in ColdFusion 2018?

With the release of ColdFusion 2018 came some adjustments and updates to Scheduled Tasks and the cfschedule tag.

  • The attribute requestimeout is removed.
  • cfschedule action=pauseall and resumeall no longer require group or mode.

For example:

If you run <cfschedule action=”pauseall” from app1, all server and application tasks of app1 are paused. It will not pause/resumeall tasks of app2.

However, application boundaries still exist. App1 cannot pause/resumeall tasks of app2and vice-versa. But any application can pause/resumeall all the server level tasks.

On October 7, 1913 at the Highland Park Ford Plant, history was made. This was day and location in which Henry Ford (of automobile fame) put into action the world’s first moving assembly line process. This maneuver was huge. Previously, all other automobiles were made piecemeal, handcrafted by specialty tradesmen. With the introduction of the assembly line, Ford had increased his production 8-fold with less manpower! The only bottleneck in production came during the painting phase. It wouldn’t dry fast enough.

This event revolutionized the production processes of the world and can be looked at as an early form of automation.

Now sure, there weren’t computers back then. But this was automation of its time. Automation by definition is:

“the technology by which a process or procedure is performed with minimum human assistance.”-Wikipedia

Obviously, we’ve come a long way from the days of Henry Ford. Especially in the realms of Information Technology and Computer Science. Our very own Adobe ColdFusion platform is no stranger to automation either. ColdFusion allows for the use of Scheduled Tasks.

ColdFusion Scheduled Tasks allow you to execute any given ColdFusion template at any given moment in time. Heck, in all reality, it doesn’t even have to be a ColdFusion template. Just as long as whatever executable action is accessible via URL.

In today’s modern age, automation is inevitable. Yet there are still many companies out there that haven’t made the leap. Why not though? Let’s take a look at some of the pros and cons of automation.

Pros and Cons of CF Automation

  • Pros
  • Increased Productivity and Throughput
  • Increased Quality of Output
  • Higher Consistency Achieved
  • Reduces Op Time and Work Handling Time Exponentially
  • Reduced Operation Cycle Times
  • Cons
  • Increased Security Vulnerability (only if you allow it)
  • May Lead to Unpredictable Development Costs
  • Higher Initial Costs (This does plateau however, then begin to actually decline after system is in place.)
  • Will Demand a Proper Time Allowance for Full Implementation (This becomes irrelevant after getting ROI for time.)

As you can see, the pros highly outweigh the cons. Especially seeing as these cons all self-correct after an automation system has been properly implemented.

Future-proofing your Business

Automation can also affect your business positively on the business end, not just operations. These following 5 advantages can help future-proof your business by making sure your staff and customers keep your company alive.

  1. Improve your Employee Morale, Retention, and Productivity
  2. There are many who may believe that automated tasks actually drive away and replace employees. This couldn’t be any farther from the truth. In all reality, automation and scheduled tasks normally target the tedious, mind-numbing tasks employees dread doing. By automating, your employees are now free to explore more productive avenues thus increasing morale and ultimately retention.
  3. Streamline your Workflow
  4. Use automation to your advantage. Automation and scheduled tasks can be utilized for better organization within your company. For instance, set up tasks to execute daily processes. This way you and your staff can focus on more pressing issues.

Related: CF India Summit: Part One — Workflow and Document Management Made Easy w/ ColdFusion

  1. Increase your Transparency to your Staff and Clients
  2. Use scheduled tasks to automatically compile updates–such as security reports, server statuses, or completed task reports. Next, have those reports automatically scheduled to be send to the appropriate recipient. This is very important. You do not want to leave your clients or employees in the dark when it comes to important updates. Also, this once again helps you to streamline your process and minimize the amount of time spent on completing previously completed work.
  3. Enhance your Customer Experience
  4. By freeing up more time–time that was normally wasted on tedious tasks–you can allocate more time to serving your client. You can also use automated tasks to establish a standard to the client. If you have a daily automated report delivered to your client, it will be less likely that there will be constant interruption and questions from the customer side. They will be able to follow along with your workflow and more likely to follow standard procedures for communication.
  5. Create Exponential Growth
  6. This is a culmination of all the other benefits. Automation and scheduled tasks are huge drivers of growth. They are also huge indicators of the health of a company.

Implementing Automation and Scheduled Tasks

Now that we’ve determined that automation and scheduled tasking is beneficial for nearly everyone… How do you go about implementing it?

On the business end of things, implementation is not as difficult as it may seem. There are four major things you need to know as CIO to get started.

  1. Know what methods are available.
  2. Tech is constantly changing.So, it behooves us to keep up so we don’t get left behind. How can you automate if you do not know what processes are available for you to use?

Related: CF India Summit: Part Two- Keeping Up to Date With Modernized ColdFusion

  1. Know how to operate these methods.
  2. Knowing what’s available is a great start, but it takes more than just recognition to put this into play. For example, most of us CF’ers will be using ColdFusion Scheduled Tasks. We have to know how to use them first! Thankfully, great speakers such as Suchika Singh are giving awesome presentations on just how to get things done. Another great place to learn are the Adobe Docs. Or… just keep reading and check out what you can do with ColdFusion Scheduled Tasks.
  3. Know the pressure points for your business.
  4. By knowing what areas need the most work, you can most efficiently implement your automation processes. When you put more focus on automating your bottlenecks, you can focus on other pressing matters creating a smooth running business machine.
  5. Know your process designs and documentation.
  6. Before implementing any form of automation, you really need to sit down and understand just exactly what process you will be automating. Not just you either. Training should be held for the appropriate staff members as well. One of the drawbacks that can come from automation is that people tend to forget the principles of an action after it has become automated. Use automation and scheduled tasks to your advantage, but never take them for granted

Now these are just a smattering of what ColdFusion scheduled tasks can do for you. The potential for this type of automation in just too great. However, you must make sure you implement these properly within your workspace. But once you start taking advantage of CF scheduling, your life as a developer will only become that much easier.

Join the CF Alive revolution

Discover how we can all make CF more alive, modern and secure this year. Join other ColdFusion developers and managers in the CF Alive Inner Circletoday.

  • Get early access to the CF Alive book and videos
  • Be part of a new movement for improving CF’s perception in the world.
  • Contribute to the CF Alive revolution
  • Connect with other CF developers and managers
  • There is no cost to membership.

Originally published at teratech.com on December 21, 2018.

Comments (0)
Add your comment