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.
Dim objQ
Set objQ = CreateObject("ScriptQ.Queue")
objQ.Add "ScriptQ.Echo ""Hello World!"""
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:
Argument | Description |
---|
sScript | The 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.
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<job>
<language>VBScript</language>
<priority>medium</priority>
<timeout>10000</timeout>
<retry-count>0</retry-count>
<id>64C5420F-9986-4BFF-A18E-9A51D3734F0F</id>
<description>Greetings</description>
<script>
<![CDATA[
Dim varItem
For Each varItem In ScriptQ.JobArguments
ScriptQ.Echo varItem
Next
]]>
</script>
<async>yes</async>
<group-id></group-id>
<retry-delay>5</retry-delay>
<argument>
<value><![CDATA[Hello World!]]></value>
</argument>
<argument>
<value><![CDATA[Happy New Year!]]></value>
</argument>
<argument>
<value><![CDATA[Bon Voyage!]]></value>
</argument>
</job>
Download XML file
The following table describes each element in the XML document.
XPath | Description |
---|
job | This element contains the job definition. |
job/language | This value is the language of the script. Possible values are: VBScript or JavaScript . |
job/priority | This value is the priority of execution for the job. Possible values are: low , medium , high or urgent . |
job/timeout | This value is the number of milliseconds before the job times out. |
job/retry-count | This is the number of attempts ScriptQ will make in order to execute the job in the event the job fails. |
job/id | This is the ID of the job. |
job/description | This is the description of the job. |
job/script | This is the actual script of the job. |
job/async | This value indicates if the job was submitted into ScriptQ asynchronously. Possible values are: yes or no . |
job/group-id | This is an identifier used to group job execution. |
job/retry-delay | This is the number of seconds between re-try attemps. |
job/argument | This element contains an argument definition. |
job/argument/value | This 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.