You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

This job template can be used to send mail from an Agent.

  • The job template makes use of the SMTP protocol to send mail.
  • The job template can be used to specify settings from different sources:
    • Connection Settings
      • This includes settings such as the SMTP host, port etc.
      • It is recommended to use JS7 - Job Resources for this purpose as such settings tend to use the same values for any mail that should be sent.
    • Mail Settings
      • Such settings are specific for individual mail and include e.g. the subject and body of the mail.

Usage

When defining the job consider

  • to specify an Agent that should execute the job,
  • to select the JITL job class,
  • to specify the com.sos.jitl.jobs.mail.MailJob Java class name,
  • to provide variables specifying what to send and where to send mail.

You can use the job wizard like this:


Explanation:

  • Add an empty job from the instruction panel.
  • Specify a name and a label for the job.
  • Select an Agent.

In a next step invoke the job wizard that you find in the upper right corner of the job property editor. The wizard brings up the following popup window:


Explanation:

  • From the list of available job templates select the MailJob.

Then hit the "Next" button to make the job wizard display available job variables:


Explanation:

  • Required job variables include the to variable to specify the recipient of mail.
  • Any other variables are optional provided that a job resource is used that specifies connection details to your mail server. Otherwise individual settings such as the SMTP host, port etc. can be specified from variables.
  • Select the check box provided with each job variable if you want this variable to be added to the arguments of the mail job.

When hitting the "Submit" button the wizard adds the required variables to your job that should look like this:


The job arguments can be specified

  • from individual variables as offered by the job wizard.
  • by use of a job resource.

Use of Job Resource for Mail Settings

A number of settings for sending mail most probably carry the same values when used for a number of mail jobs. This includes e.g. the SMTP host, SMTP port etc.

  • You can specify such settings individually from variables that are assigned the job's arguments, see above.
  • You can specify such settings from JS7 - Job Resources that can be re-used for any number of mail jobs.

Setting up a Job Resource for Mail Settings

You can create a job resource that includes any settings required to send mail.

A job resource has two parts, one being the variables that can be specified like this from the "Arguments" sub-tab:


Explanation:

  • The variable names specified are selected to match use with the JITL MailJob template.
  • Consider the use of variable names that start with mail.smtp.

The second part of a job resource is available with the "Environment Variables" sub-tab:


Explanation:

  • Values of environment variables are assigned the corresponding variables as explained with the previous chapter.
  • The purpose of the "Environment Variables" sub-tab is to propagate variables to shell jobs should you operate jobs that require such environment variables for parameterization purposes.
  • Consider that the JITL MailJob is a job running in the Java Virtual Machine. It is not a shell job and therefore does not use environment variables.

Assigning a Job Resource for Mail Settings

With a job resource being created and deployed it can be assigned the JITL MailJob to populate the job's arguments from the job resource like this:

Use of Arguments

The com.sos.jitl.jobs.mail.MailJob class accepts the following arguments:


NameRequiredDefault ValuePurpose
commandyes
Carries the SQL statements.

hibernate_configuration_file

no./config/hibernate.cfg.xml

Specifies the configuration file (XML) format for Hibernate connections, see JS7 - Database. By default Agents ship without hibernate configuration files, however, if a file with the default name is available then it will be applied.

resultset_as_warning

no

Raises a warning if the SQL statement creates a result set.

exec_returns_resultset

no

If stored procedures are called that return a result set then this argument has to be set to true in order to run the stored procedure as a query.

resultset_as_variables

no

Specifies how a result set is forwarded to order variables for subsequent jobs:

  • false: no result set is processed (default)
  • column_value: for the first record of the result set from each column name a variable is created that holds the column value.
  • name_value:  the first two columns of the result set will be added to order variables. The values of the first column of each record included with the result set will become the variable names, the values of the second column will become the variable values. 


Explanation:

  • Note that it is possible to define more than one instruction with the command argument.
    Such instructions are then carried out in the order in which they are written and must be separated by a semicolon.
    • Some DBMS might require and additional newline character.
    • For example
      • update MY_TABLE set a='foo' where b='bar'; commit;
  • Note also that order variables and arguments can be injected to the SQL statement(s) of the command argument by use of the ${variable} syntax.

Further information


  • No labels