on 06-07-2021 4:07 PM
Hello Experts,
{
jcsPostRunningContext.setFailJobOnError(false) ;
jcsPostRunningContext.setMaximumRestarts(5) ;
jcsPostRunningContext.setLogRestarts(false) ;
// definition of job witch failed
JobDefinition jcsJobDefinition = jcsJob.getJobDefinition();
Partition jcsPartition = jcsJobDefinition.getPartition();
if((!jcsJobDefinition.getJobDefinitionType().getName().equals(JobDefinitionType.JOB_CHAIN)) && (!jcsPartition.getName().equals("GLOBAL"))) {
// not a jobchain
Table System_Variables = jcsSession.getTableByName("System_Variables");
String MailRecipients = System_Variables.getTableValueBySearchKeySearchColumnName("ALERT_RECIPIENTS", "SYSTEMVALUE").getColumnValue();
if (jcsPostRunningContext.getNewStatus().equals(JobStatus.Error) || jcsPostRunningContext.getNewStatus().equals(JobStatus.Killed)) {
// Error and Kill status
String jcsMailRecipients = MailRecipients + isMail(jcsJobDefinition.getComment()) + isMail(jcsJobDefinition.getParentApplication().getComment());
String jcsJobName = jcsJobDefinition.getName();
// Parent jo handling
Job jcsParentJob = jcsJob.getParentJob();
if(jcsParentJob != null) {
// get mail from parent job and it's aplication
jcsMailRecipients = jcsMailRecipients + isMail(jcsParentJob.getJobDefinition().getComment()) + isMail(jcsParentJob.getJobDefinition().getParentApplication().getComment());
jcsJobName = jcsParentJob.getJobDefinition().getName() + " - step [" + jcsJobName + "]";
jcsPartition = jcsParentJob.getJobDefinition().getPartition();
}
// Partition description
String jcsDescription = jcsPartition.getComment();
if(jcsDescription == null)
jcsDescription = jcsPartition.getName();
// Start mail job now
Job jcsMailJob = jcsSession.getJobDefinitionByName("Alert_Send_Mail_Job_Alert").prepare();
// jcsMailRecipients = System_Variables.getTableValueBySearchKeySearchColumnName("ALERT_RECIPIENTS", "SYSTEMVALUE").getColumnValue();
jcsMailJob.getJobParameterByName("Mail_To").setInValueString(jcsMailRecipients);
jcsMailJob.getJobParameterByName("Error_JobID").setInValueString(jcsJob.getJobId().toString());
jcsMailJob.getJobParameterByName("Error_Description").setInValueString(jcsDescription + " - Error in job '" + jcsJobName + "'");
}
if (jcsPostRunningContext.getNewStatus().equals(JobStatus.Unknown)) {
// Unknown status handling
Job jcsMailJob = jcsSession.getJobDefinitionByName("Alert_Send_Mail_Job_Alert").prepare();
jcsMailJob.getJobParameterByName("Mail_To").setInValueString(MailRecipients);
jcsMailJob.getJobParameterByName("Error_JobID").setInValueString(jcsJob.getJobId().toString());
jcsMailJob.getJobParameterByName("Error_Description").setInValueString("Job '" + jcsJobDefinition.getName() + "' has got the status Unknown. Please investigate.");
}
}
}
private String isMail(String str) {
if(str == null)
return "";
if(str.indexOf("@") < 0)
return "";
if(str.indexOf(" ") >= 0)
return "";
if(str.indexOf("#") >= 0)
return "";
return "," + str.toLowerCase();
}
Hello,
Add a check on the remote status in your first if statement:
if(!jcsJobDefinition.getJobDefinitionType().getName().equals(JobDefinitionType.JOB_CHAIN) && !jcsPartition.getName().equals("GLOBAL") && !"Warning".equals(jcsJob.getRemoteStatus()))
{
//not a jobchain and not remote status is Warning
Regards Gerben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.