Table of Contents |
---|
| outlinh1. true |
---|
| outlinh1. true |
---|
1 | printablefalse |
---|
2 | stylh1. none |
---|
3 | indent20px |
---|
|
The JITL jobs JSSmtpMailClientAdapter and SmtpMailMonitor are included since JobScheduler Release 1.5.3253.
These job is now without a documentation. It is useful for sending emails.
It contains all parameters like the JobSchedulerManagedMailJob.
SmtpMailMonitor can used for a pre- or post-processing.
...
Code Block |
---|
|
<job>
<params >
<param name="MailOnSuccess_host" value="my_smtp"/>
<param name="MailOnSuccess_subject" value="%SCHEDULER_JOB_NAME% has run successfully"/>
<param name="MailOnSuccess_body" value="%SCHEDULER_JOB_NAME% has run successfully"/>
<param name="MailOnSuccess_to" value="mymail@address.com"/>
</params>
<script language="shell">
<![CDATA[
echo foo
]]>
</script>
<monitor name="sendMail" ordering="0">
<script language="java" java_class="com.sos.jitl.mail.smtp.SmtpMailMonitor"/>
</monitor>
<run_time />
</job>
|
...
For each prefix you can specify e.g. different recipients.
You want that a job should sends a mail in the case of an error in the normal way via the JobScheduler mail notification.
This mail has the task log as attachment.
Further you want a success mail but without the task log, so deactivate the mail via JobScheduler (see <settings> in the following example) and
specify some parameter with the "MailOnSuccess_" prefix.
Code Block |
---|
|
<job>
<settings>
<mail_on_error><![CDATA[yes]]></mail_on_error>
<mail_on_warning><![CDATA[yes]]></mail_on_warning>
<mail_on_success><![CDATA[no]]></mail_on_success>
</settings>
<params>
<param name="host" value="my_smtp"/>
<param name="MailOnSuccess_to" value="mymail@address.com"/>
<param name="MailOnSuccess_body" value="%SCHEDULER_JOB_NAME% has run successfully"/>
<param name="MailOnSuccess_subject" value="%SCHEDULER_JOB_NAME% has run successfully"/>
</params>
<script language="shell">
<![CDATA[
exit 0
]]>
</script>
<monitor name="process0" ordering="0">
<script java_class="com.sos.jitl.mail.smtp.SmtpMailMonitor" java_class_path="" language="java"/>
</monitor>
<run_time/>
</job>
|
Example job using com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterClass:
Code Block |
---|
|
<job>
<params>
<param name="subject" value="Test-Mail"/>
<param name="body" value="This is the body"/>
<param name="to" value="myMail@address.com"/>
<param name="host" value="my_smtp"/>
</params>
<script language="java" java_class="com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterClass"/>
<run_time/>
</job>
|
The can substitute its parameters with other parameters.
We assume that we have a job chain with two jobs. The first job transfers files and if the first job has an error than the seconds job starts to send an email. Otherwise the job chain ends after the first job. The body of the email should have the error of the first job.
The first job writes its last error in a post-processing into the order parameter with the name last_error and the mail job has a parameter
Code Block |
---|
|
<param name="body" value="ERROR: %last_error%"/>
|
...
Code Block |
---|
|
<job_chain orders_recoverable="yes">
<job_chain_node error_state="mail" next_state="success" state="100" job="jade"/>
<job_chain_node error_state="error" next_state="error" state="mail" job="sendMail"/>
<job_chain_node state="error"/>
<job_chain_node state="success"/>
</job_chain>
|
...
Code Block |
---|
|
<job order="yes" stop_on_error="no" title="API Job for JobScheduler Advanced Data Exchange">
<settings>
<mail_on_error><![CDATA[no]]></mail_on_error>
</settings>
<description>
<include file="jobs/jadeJob.xml"/>
</description>
<params>
...
</params>
<script java_class="sos.scheduler.jade.JadeJob" language="java"/>
<monitor name="setLastError" ordering="0">
<script language="javax.script:rhino"><![CDATA[
function spooler_process_after(spooler_process_result)\ {
spooler_task.order().params().set_var('last_error',spooler_log.last(2));
return spooler_process_result;
\}
]]>
</script>
</monitor>
<run_time/>
</job>
|
...
Code Block |
---|
|
<job order="yes" stop_on_error="no" title="Send Mails">
<params>
<param name="subject" value="Test-Mail"/>
<param name="body" value="ERROR: %last_error%"/>
<param name="to" value="myMail@address.com"/>
<param name="host" value="my_smtp"/>
</params>
<script java_class="com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterClass" language="java"/>
<run_time/>
</job>
|