Date: Fri, 29 Mar 2024 10:26:06 +0000 (UTC) Message-ID: <1649005527.12753.1711707966400@change.sos-berlin.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_12752_1322735307.1711707966399" ------=_Part_12752_1322735307.1711707966399 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The JITL jobs JSSmtpMailClientAdapter and SmtpMailMonitor=
em> 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.
Example job using com.sos.jitl.mail.smtp.SmtpMailMonitor:
<= ;job> <params > <param name=3D"MailOnSuccess_host" value=3D"my_smtp"/> <param name=3D"MailOnSuccess_subject" value=3D"%SCHEDULER_JOB_N= AME% has run successfully"/> <param name=3D"MailOnSuccess_body" value=3D"%SCHEDULER_JOB_NAME= % has run successfully"/> <param name=3D"MailOnSuccess_to" value=3D"mymail@address.com"/&= gt; </params> <script language=3D"shell"> <![CDATA[ echo foo ]]> </script> <monitor name=3D"sendMail" ordering=3D"0"> <script language=3D"java" java_class=3D"com.sos.jitl.mail.smtp.= SmtpMailMonitor"/> </monitor> <run_time /> </job>
For this job you should use prefixes "MailOnSuccess_", "MailOnError_" an= d "MailOnJobStart_".
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 n=
ormal 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 th=
e mail via JobScheduler (see <settings> in the following example) and=
specify some parameter with the "MailOnSuccess_" prefix.
<= ;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=3D"host" value=3D"my_smtp"/> <param name=3D"MailOnSuccess_to" value=3D"mymail@address.com"/> <param name=3D"MailOnSuccess_body" value=3D"%SCHEDULER_JOB_NAME% has= run successfully"/> <param name=3D"MailOnSuccess_subject" value=3D"%SCHEDULER_JOB_NAME% = has run successfully"/> </params> <script language=3D"shell"> <![CDATA[ =20 exit 0 =20 ]]> </script> <monitor name=3D"process0" ordering=3D"0"> <script java_class=3D"com.sos.jitl.mail.smtp.SmtpMailMonitor" java_c= lass_path=3D"" language=3D"java"/> </monitor> <run_time/> </job>
Example job using com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterClass:= p>
<= ;job> <params> <param name=3D"subject" value=3D"Test-Mail"/> <param name=3D"body" value=3D"This is the body"/> <param name=3D"to" value=3D"myMail@address.com"/> <param name=3D"host" value=3D"my_smtp"/> </params> <script language=3D"java" java_class=3D"com.sos.jitl.mail.smtp.JSSmtp= MailClientAdapterClass"/> <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 th=
e email should have the error of the first job.
The first job writes its last error in a post-processing into the order pa=
rameter with the name last_error and the mail job has a parameter<=
/p>
&= lt;param name=3D"body" value=3D"ERROR: %last_error%"/>
for the body. Then the value of the last_error parameter is sub= stituted into the body parameter.
Configuration of the job chain
<= ;job_chain orders_recoverable=3D"yes"> <job_chain_node error_state=3D"mail" next_state=3D"success" state=3D"1= 00" job=3D"jade"/> <job_chain_node error_state=3D"error" next_state=3D"error" state=3D"ma= il" job=3D"sendMail"/> <job_chain_node state=3D"error"/> <job_chain_node state=3D"success"/> </job_chain>
Configuration of the first job for file transfer
<= ;job order=3D"yes" stop_on_error=3D"no" title=3D"API Job for JobScheduler A= dvanced Data Exchange"> <settings> <mail_on_error><![CDATA[no]]></mail_on_error> </settings> <description> <include file=3D"jobs/jadeJob.xml"/> </description> <params> ... </params> <script java_class=3D"sos.scheduler.jade.JadeJob" language=3D"java"/&g= t; <monitor name=3D"setLastError" ordering=3D"0"> <script language=3D"javax.script:rhino"><![CDATA[ =20 function spooler_process_after(spooler_process_result) { =09spooler_task.order().params().set_var('last_error',spooler_log.last(2)); =09return spooler_process_result; } =20 ]]> </script> </monitor> <run_time/> </job>
Configuration of the second job for sending mails in the case of an erro= r
<= ;job order=3D"yes" stop_on_error=3D"no" title=3D"Send Mails"> <params> <param name=3D"subject" value=3D"Test-Mail"/> <param name=3D"body" value=3D"ERROR: %last_error%"/> <param name=3D"to" value=3D"myMail@address.com"/> <param name=3D"host" value=3D"my_smtp"/> </params> <script java_class=3D"com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterCl= ass" language=3D"java"/> <run_time/> </job>