Просмотр исходного кода

忽略自动启动规则错误

zhou-hao 4 лет назад
Родитель
Сommit
f19c3421b4

+ 14 - 9
jetlinks-manager/rule-engine-manager/src/main/java/org/jetlinks/community/rule/engine/service/RuleInstanceService.java

@@ -45,9 +45,9 @@ public class RuleInstanceService extends GenericReactiveCrudService<RuleInstance
         return this.ruleEngine
             .shutdown(id)
             .then(createUpdate()
-                .set(RuleInstanceEntity::getState, RuleInstanceState.stopped)
-                .where(RuleInstanceEntity::getId, id)
-                .execute())
+                      .set(RuleInstanceEntity::getState, RuleInstanceState.stopped)
+                      .where(RuleInstanceEntity::getId, id)
+                      .execute())
             .then();
     }
 
@@ -62,17 +62,17 @@ public class RuleInstanceService extends GenericReactiveCrudService<RuleInstance
             return ruleEngine
                 .startRule(entity.getId(), model)
                 .then(createUpdate()
-                    .set(RuleInstanceEntity::getState, RuleInstanceState.started)
-                    .where(entity::getId)
-                    .execute()).then();
+                          .set(RuleInstanceEntity::getState, RuleInstanceState.started)
+                          .where(entity::getId)
+                          .execute()).then();
         });
     }
 
     @Override
     public Mono<Integer> deleteById(Publisher<String> idPublisher) {
         return Flux.from(idPublisher)
-            .flatMap(id -> this.stop(id).thenReturn(id))
-            .as(super::deleteById);
+                   .flatMap(id -> this.stop(id).thenReturn(id))
+                   .as(super::deleteById);
     }
 
     @Override
@@ -81,7 +81,12 @@ public class RuleInstanceService extends GenericReactiveCrudService<RuleInstance
             .where()
             .is(RuleInstanceEntity::getState, RuleInstanceState.started)
             .fetch()
-            .flatMap(this::doStart)
+            .flatMap(e -> this
+                .doStart(e)
+                .onErrorResume(err -> {
+                    log.warn("启动规则[{}]失败", e.getName(), e);
+                    return Mono.empty();
+                }))
             .subscribe();
     }
 }