Browse Source

The SQL task fails if the mail delivery fails

pull/2/head
lgcareer 6 years ago
parent
commit
597f518ed5
  1. 1
      escheduler-alert/src/main/java/cn/escheduler/alert/utils/MailUtils.java
  2. 9
      escheduler-server/src/main/java/cn/escheduler/server/worker/task/sql/SqlTask.java

1
escheduler-alert/src/main/java/cn/escheduler/alert/utils/MailUtils.java

@ -160,6 +160,7 @@ public class MailUtils {
return retMap; return retMap;
}catch (Exception e){ }catch (Exception e){
handleException(receivers, retMap, e); handleException(receivers, retMap, e);
return retMap;
} }
} }
return retMap; return retMap;

9
escheduler-server/src/main/java/cn/escheduler/server/worker/task/sql/SqlTask.java

@ -17,6 +17,7 @@
package cn.escheduler.server.worker.task.sql; package cn.escheduler.server.worker.task.sql;
import cn.escheduler.alert.utils.MailUtils; import cn.escheduler.alert.utils.MailUtils;
import cn.escheduler.api.enums.Status;
import cn.escheduler.common.Constants; import cn.escheduler.common.Constants;
import cn.escheduler.common.enums.DbType; import cn.escheduler.common.enums.DbType;
import cn.escheduler.common.enums.ShowType; import cn.escheduler.common.enums.ShowType;
@ -310,6 +311,7 @@ public class SqlTask extends AbstractTask {
} }
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage());
} }
return connection; return connection;
} }
@ -371,9 +373,14 @@ public class SqlTask extends AbstractTask {
String showTypeName = sqlParameters.getShowType().replace(Constants.COMMA,"").trim(); String showTypeName = sqlParameters.getShowType().replace(Constants.COMMA,"").trim();
if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){ if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){
MailUtils.sendMails(receviersList,receviersCcList,title, content, ShowType.valueOf(showTypeName)); Map<String, Object> mailResult = MailUtils.sendMails(receviersList, receviersCcList, title, content, ShowType.valueOf(showTypeName));
Status status = (Status) mailResult.get(cn.escheduler.api.utils.Constants.STATUS);
if(status != Status.SUCCESS){
throw new RuntimeException("send mail failed!");
}
}else{ }else{
logger.error("showType: {} is not valid " ,showTypeName); logger.error("showType: {} is not valid " ,showTypeName);
throw new RuntimeException(String.format("showType: %s is not valid ",showTypeName));
} }
} }

Loading…
Cancel
Save