JAMS Developer Guide
Creating a Custom Execution Method

In This Topic

 

Creating a custom Execution Method can be very helpful in customizing how JAMS runs jobs.  It is possible to utilize a technology which JAMS does not interface with out of the box, or modify an existing Execution Method to add or customize functionality. In this guide, you will copy an existing Execution Method and modify how it runs jobs. The example will cover copying the Parsed Windows Command procedure to a new Execution Method, with added custom functionality.

 Create a new Execution Method in the JAMS GUI

  1. In the JAMS Client, open the Execution Methods shortcut from the Configuration group.
  2. Click the Add button to open the Execution Method Creation Wizard.
  3. Give the Execution Method a unique name. This name will be used when modifying how the Execution Method runs Jobs.
    NOTE: Do not use a name with spaces. Concatenate the name, or use underscores.
  4. Select the Command Execution Method as a base.
  5. Ensure Edit the Execution Method after adding is checked, then click Finish.
  6. The Execution Method Properties dialog will now appear.
  7. Navigate to the Source tab, and set the Default File Extension to cmd. In the Job Module field, enter the name of the newly created Execution Method. In this example, the name is CustomParsed.
  8. Navigate to the Execution tab, and ensure the Type is set to Batch.
  9. Ensure the Command field value is set to: cmd.exe /c "{0}"

    Note that the settings in this example do not reflect all of the options available for creating custom Execution Methods, and that the settings for a custom created Execution Method will vary by use case.
  10. Save and Close the Execution Method Properties dialog.

 

Edit BaseMacros.xml to configure how the new Execution Method runs

With the Custom Execution Method created, modify how the execution method runs jobs by editing the BaseMacros.xml file. This file provides JAMS with a template for parsing a Job's command procedure.

  1. Open the BaseMacros.xml file, located at C:\Program Files\MVPSI\JAMS\Scheduler\BaseMacros.xml by default.
  2. Macros for Execution Methods exist between the <ArrayOfMacro></ArrayOfMacro> tags. As this example expands on existing functionality of the Parsed Command Execution Method, begin by copying the existing Parsed Macro.
  3. Paste the copied Macro between the <ArrayOfMacro> and </ArrayOfMacro> tags. To ensure no existing Macro code is interrupted, it is recommended that users paste the copied code directly preceeding the </ArrayOfMacro> tag.
  4. Edit the new Macro's name to reflect the name of the newly created Execution Method. In this example, the name is CustomParsed.
  5. Begin to edit the Macro itself. When a Job runs, the code contained within the <Code></Code> tags will be evaluated by JAMS, and then sent to where the execution method properties specify.
    NOTE: JAMS can retrieve data from the Job currently executing. This data is then used to execute the Job. Data is contained within the <<>> tags. JAMS can also evaluate and insert other macros, which are contained in the <%%> tags. In the copied Macro shown above, the JAMS.Parameters collection and JAMS.Source property are being referenced. The Objects that users can retrieve data from are as follows:

    Object Description
    Job Only accessible when running a Job
    Current The CurJob object
    Node A NodeInfo object
    Source The Source property provided by the Job
    NotifyEMail The final list of email addresses to be notified. This is a combination of e-mail addresses from the DefaultNotifyEmail config setting, Folder, and Job notify lists.
    Folder A Folder object

    Any of these objects can be referenced by using the format <<JAMS.ObjectName>>. So, to retrieve a description of the Folder this job is running under, users would use <<JAMS.Folder.Description>> in the macro. It is possible to access any public property from any of the above objects. If one of the above objects are not specified, the Current object is inserted.  So, in the macro source, <<JAMS.JobName >> and <<JAMS.Current.JobName >> would evaluate to the same value. Users can also access parameters and variables in the Macro by using the typical <<ParameterName>> format. Users can also add any formatting supported by the .NET String.Format method to values. A list of these formats can be found here: http://msdn.microsoft.com/en-us/library/fbxft59x.aspx

  6. Using the information above, insert the relevant objects into the Macro code. In the sample below, the current Job Name, the Job Description, and the Folder Name are used.
    CustomParsed
    Copy Code

    <Macro name="CustomParsed">

      <Code>

        <![CDATA[REM JAMS Custom Parsed Macro

        REM Job Name: <<JAMS.Current.JobName>>

        REM Job Description: <<JAMS.Job.Description>>

        REM Running under Folder: <<JAMS.Folder.FolderName>>

        <%Symbol(JAMS.Parameters)%>

        <<JAMS.Source>>

        exit %errorlevel%

        ]]>

      </Code>

    </Macro>

  7. Save the BaseMacros.xml file.
  8. Restart the JAMS Scheduler Service. This must be done every time a change is made to the BaseMacros.xml file, or the changes will not take effect.

 

Create a Job using the new Execution Method

Once the service has restarted, create a new Job to test the newly created Execution Method. Users can also change the Execution Method of an existing Job, in the Source Options tab of the Job definition.

Note: If you do not see the CustomParsed Execution Method in the dialog, you may need to hit the Refresh button in order for the newly created method to appear.

  1. Create a Job in the desired folder and choose the newly created CustomParsed execution method.
  2. Configure run-as and notification settings as desired.
  3. Enter Source as desired. For this example, the Job Source will be left blank.
  4. Set a schedule on the Job, if desired.
  5. Finish creating the Job.
  6. Manually submit the Job, then wait for the Job to complete.
  7. Open the Job Detail and navigate to the Log File tab to confirm the Execution Method is functioning as intended, providing the additional logging specified in the Macro.

 

See Also

 

 


Copyright © Fortra, LLC and its group of companies.
All trademarks and registered trademarks are the property of their respective owners.