tomsun28 commented on code in PR #2180:
URL: https://github.com/apache/hertzbeat/pull/2180#discussion_r1664950800


##########
manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java:
##########
@@ -131,29 +132,21 @@ public void run() {
         }
 
         private void sendNotify(Alert alert) {
-            List<NoticeRule> noticeRules = matchNoticeRulesByAlert(alert);
-            // todo Send notification here temporarily single thread
-            if (noticeRules != null) {
-                for (NoticeRule rule : noticeRules) {
-                    try {
-                        if (rule.getTemplateId() == null) {
-                            List<Long> receiverIdList = rule.getReceiverId();
-                            for (Long receiverId : receiverIdList) {
-                                sendNoticeMsg(getOneReceiverById(receiverId),
-                                        null, alert);
-                            }
-                        } else {
-                            List<Long> receiverIdList = rule.getReceiverId();
-                            for (Long receiverId : receiverIdList) {
-                                sendNoticeMsg(getOneReceiverById(receiverId),
-                                    getOneTemplateById(rule.getTemplateId()), 
alert);
-                            }
-                        }
-                    } catch (AlertNoticeException e) {
-                        log.warn("DispatchTask sendNoticeMsg error, message: 
{}", e.getMessage());
-                    }
-                }
-            }
+            matchNoticeRulesByAlert(alert).ifPresent(noticeRules -> {
+                noticeRules.forEach(rule -> {
+                    workerPool.executeNotify(() -> {
+                        rule.getReceiverId().stream().filter(receiverId -> 
rule.getTemplateId() != null)

Review Comment:
   hi, the code logic here is to filter out cases where the template id is 
null, but before the template id was null it would go to use the default file 
notification template.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to