DefaultNotificationRuleProcessor - submit to notificationExecutor sooner not to block the caller
This commit is contained in:
parent
a6f1b7228c
commit
ee080538a4
@ -77,18 +77,17 @@ public class DefaultNotificationRuleProcessor implements NotificationRuleProcess
|
|||||||
public void process(NotificationRuleTrigger trigger) {
|
public void process(NotificationRuleTrigger trigger) {
|
||||||
NotificationRuleTriggerType triggerType = trigger.getType();
|
NotificationRuleTriggerType triggerType = trigger.getType();
|
||||||
TenantId tenantId = triggerType.isTenantLevel() ? trigger.getTenantId() : TenantId.SYS_TENANT_ID;
|
TenantId tenantId = triggerType.isTenantLevel() ? trigger.getTenantId() : TenantId.SYS_TENANT_ID;
|
||||||
|
notificationExecutor.submit(() -> {
|
||||||
try {
|
try {
|
||||||
List<NotificationRule> enabledRules = notificationRulesCache.getEnabled(tenantId, triggerType);
|
List<NotificationRule> enabledRules = notificationRulesCache.getEnabled(tenantId, triggerType);
|
||||||
if (enabledRules.isEmpty()) {
|
if (enabledRules.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (trigger.deduplicate()) {
|
if (trigger.deduplicate()) {
|
||||||
enabledRules = new ArrayList<>(enabledRules);
|
enabledRules = new ArrayList<>(enabledRules);
|
||||||
enabledRules.removeIf(rule -> deduplicationService.alreadyProcessed(trigger, rule));
|
enabledRules.removeIf(rule -> deduplicationService.alreadyProcessed(trigger, rule));
|
||||||
}
|
}
|
||||||
final List<NotificationRule> rules = enabledRules;
|
final List<NotificationRule> rules = enabledRules;
|
||||||
notificationExecutor.submit(() -> {
|
|
||||||
for (NotificationRule rule : rules) {
|
for (NotificationRule rule : rules) {
|
||||||
try {
|
try {
|
||||||
processNotificationRule(rule, trigger);
|
processNotificationRule(rule, trigger);
|
||||||
@ -96,10 +95,10 @@ public class DefaultNotificationRuleProcessor implements NotificationRuleProcess
|
|||||||
log.error("Failed to process notification rule {} for trigger type {} with trigger object {}", rule.getId(), rule.getTriggerType(), trigger, e);
|
log.error("Failed to process notification rule {} for trigger type {} with trigger object {}", rule.getId(), rule.getTriggerType(), trigger, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
} catch (Throwable e) {
|
||||||
} catch (Throwable e) {
|
log.error("Failed to process notification rules for trigger: {}", trigger, e);
|
||||||
log.error("Failed to process notification rules for trigger: {}", trigger, e);
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processNotificationRule(NotificationRule rule, NotificationRuleTrigger trigger) {
|
private void processNotificationRule(NotificationRule rule, NotificationRuleTrigger trigger) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user