Contact Us

Let us know to help you out quickly!

 Pritesh     Feb,08 2017

Day 12: ColdFusion and Schedule Task List and Group Enhancement

 

In yesterday blog I have list out all new feature added in schedule task in ColdFusion 10. Now time to test it out, covering list, group feature in this post. While creating schedule we can put schedule in specific group and later you can pause all/resume all schedule in same group without firing individual command. And list option added in action attribute which list out all current schedules in query format.

<cfschedule startDate="11/11/2011" starttime="12:01 AM" interval="Daily" action="update" task="MyGroupedTask" url="http://www.facebook.com"  group="CallSocial"/><cfschedule startDate="11/11/2011" starttime="12:01 AM" interval="Daily" action="update" task="MyGroupedTask1" url="http://www.twitter.com"  group="CallSocial"/><cfschedule startDate="11/11/2011" starttime="12:01 AM" interval="Daily" action="update" task="MyGroupedTask2" url="http://plus.google.com"  group="CallSocial"/><cfoutput><cfschedule  action="list" result ="res" /><cfloop query="res"><div>#res.task#  [#res.url#]: #res.status#</div></cfloop><cfschedule action="pause" group="CallSocial"><hr/><cfschedule  action="list" mode="server" result ="res" /><cfloop query="res"><div>#res.task#  [#res.url#]: #res.status#</div></cfloop><cfschedule action="resume" group="CallSocial"><cfschedule  action="list" mode="server" result ="res" /><hr/><cfloop query="res"><div>#res.task#  [#res.url#]: #res.status#</div></cfloop></cfoutput>

First three statements will create schedule task and all grouped to name "CallSocial". Group attribute is optional and if not provided schedule will go under default group. Also for ColdFusion 10 startDate and starttime are also optional for update action and will consider as chained schedule if startDate and startTime not provided.

Main advantage of grouping schedule task is you can pause or resume all grouped task together and this will make easier to manage task programmatically we just need to provide group name as attribute with action option 'pause' or 'resume'. Don't try with other action or will raise attribute validation error :). Here is output.

MyGroupedTask [http://www.facebook.com]: Running
MyGroupedTask1 [http://www.twitter.com]: Running
MyGroupedTask2 [http://plus.google.com]: Running

MyGroupedTask [http://www.facebook.com]: Paused
MyGroupedTask1 [http://www.twitter.com]: Paused
MyGroupedTask2 [http://plus.google.com]: Paused

MyGroupedTask [http://www.facebook.com]: Running
MyGroupedTask1 [http://www.twitter.com]: Running
MyGroupedTask2 [http://plus.google.com]: Running 

 

Hope this help.