Automated Workflow activity script

The Workflow service can handle a limited number of activities at the same time. This limit is configurable in the SDL Tridion MMC Snap-in using the Workflow Settings > Number of threads for running automated scripts setting.

If more than one activity is designed to run for a longer period of time, you can prevent the pool of threads from filling up by distinguishing between normal and long-running activities.

To support long running activities, three methods are included in the API:

  • Snooze—this setting indicates that the automated activity is long running. The priority of the thread on which the automated activity is running is decreased. The thread is not counted when the thread limit is calculated.
  • WakeUp—this setting indicates that an automated activity is no longer long-running. The priority of the thread on which the automated activity is running is changed back to normal. The thread counts when the thread limit is calculated.
  • Sleep (long milliseconds)—this setting indicates the time (milliseconds) for which the automated activity will sleep. This method can be used when the automated script wants to check if information is available. If information is not available, the thread can sleep for the specified amount of time and does not use processing power. Typically, this method can be used if the automated activity is set to Snooze.

The following example shows a long running automated activity that uses these methods:

' Do some initialization 
Call Snooze()
' Wait till 09:00 oclock to finish the activity
While Hour( Now ) <> 9
Call Sleep( 60000 ) ' sleep for 1 minute
WEnd 
Call WakeUp() 
' Finish the activity
Call FinishActivity( "Finished" )