The XHTML WYSIWYG Editor For Desktop & Web Applications

Running A Job

Overview

There are two ways to submit jobs to ScriptQ. The first method is to programmatically add a job through a COM API. The second method is to put a job definition in an XML document into the Pickup or Priority folder. A job can also be submitted through a graphical user interface in ScriptQ Monitor which creates an XML definition for the job and places it into the Pickup or Priority folder.

API Approach

Jobs can be added to ScriptQ programmatically through a COM API. Here is a VBScript example of adding a job to ScriptQ.

  1. Dim objQ
  2. Set objQ = CreateObject("ScriptQ.Queue")
  3. objQ.Add "ScriptQ.Echo ""Hello World!"""
  4. Set objQ = Nothing

The API for adding a job is:

Function Add(sScript As String, [bAsync As Boolean = True], [sLanguage As String = "VBScript"], [sDescription As String], [lPriority As Long = 2], [sGroupID As String], [lRetryDelay As Long = 60], [lTimeout As Long = 5000], [lRetryCount As Long], [sID As String], [vArguments As Variant]) As Boolean

The following table describes each argument:

ArgumentDescription
sScriptThe code for the script.
bAsync(Optional) This value determines if the job is submitted synchronously or asynchronously.
sLanguage(Optional) This value is the language of the script. Possible values are VBScript or JavaScript.
sDescription(Optional)This is a user-friendly description of the job.
lPriority(Optional)This value is the priority of the job and helps ScriptQ sequence job execution order. The following values are available:
1 = Low
2 = Medium
3 = High
4 = Urgent
sGroupID(Optional)This value is used to group jobs together.
lRetryDelay(Optional)This value is the number of seconds before ScriptQ attempts to re-execute a failed job.
lTimeout(Optional)This value is the maximum number of milliseconds before a job is stopped by ScriptQ.
lRetryCount(Optional)This value is the number of attempts that should be made to execute a job if it fails.
sID(Optional)This is a unique value that identifies a job.
vArguments(Optional)This is an array of arguments for the script. The script can programmatically read the values when it is executing.

When the Queue Size Limit is exceeded, jobs with high or urgent priority status and jobs that rely on grouping will be added to the queue, while other jobs will be placed into the Pickup folder.

Pickup Approach

Jobs can be added to ScriptQ by placing a properly structured XML document into the Pickup or Priority folders. Below is an example of an XML document containing a job definition.

  1. <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
  2. <job>
  3. <language>VBScript</language>
  4. <priority>medium</priority>
  5. <timeout>10000</timeout>
  6. <retry-count>0</retry-count>
  7. <id>64C5420F-9986-4BFF-A18E-9A51D3734F0F</id>
  8. <description>Greetings</description>
  9. <script>
  10. <![CDATA[
  11. Dim varItem
  12. For Each varItem In ScriptQ.JobArguments
  13. ScriptQ.Echo varItem
  14. Next
  15. ]]>
  16. </script>
  17. <async>yes</async>
  18. <group-id></group-id>
  19. <retry-delay>5</retry-delay>
  20. <argument>
  21. <value><![CDATA[Hello World!]]></value>
  22. </argument>
  23. <argument>
  24. <value><![CDATA[Happy New Year!]]></value>
  25. </argument>
  26. <argument>
  27. <value><![CDATA[Bon Voyage!]]></value>
  28. </argument>
  29. </job>

Download XML file

The following table describes each element in the XML document.

XPathDescription
jobThis element contains the job definition.
job/languageThis value is the language of the script. Possible values are: VBScript or JavaScript.
job/priorityThis value is the priority of execution for the job. Possible values are: low, medium, high or urgent.
job/timeoutThis value is the number of milliseconds before the job times out.
job/retry-countThis is the number of attempts ScriptQ will make in order to execute the job in the event the job fails.
job/idThis is the ID of the job.
job/descriptionThis is the description of the job.
job/scriptThis is the actual script of the job.
job/asyncThis value indicates if the job was submitted into ScriptQ asynchronously. Possible values are: yes or no.
job/group-idThis is an identifier used to group job execution.
job/retry-delayThis is the number of seconds between re-try attemps.
job/argumentThis element contains an argument definition.
job/argument/valueThis is the value of an argument.

The difference between the Pickup folder and the Priority folder concerns how jobs are picked-up when the Queue Size Limit is exceeded. When this value is exceeded, all jobs placed into the Priority folder will continue to be picked-up and placed into the queue. Jobs from the Pickup folder will only be picked up when the number of jobs in the queue drops below the Queue Size Limit. It is recommended that high and urgent priority jobs and jobs that rely of grouping be placed into the Priority folder, and that all other jobs be placed into the Pickup folder.