Browse Source

Improve notification center broadcast logic

pull/9083/head
Andrii Landiak 3 years ago
parent
commit
efe5580716
  1. 6
      application/src/main/java/org/thingsboard/server/service/entitiy/EntityStateSourcingListener.java
  2. 4
      application/src/main/java/org/thingsboard/server/service/notification/DefaultNotificationCenter.java
  3. 4
      dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationRequestService.java

6
application/src/main/java/org/thingsboard/server/service/entitiy/EntityStateSourcingListener.java

@ -138,6 +138,7 @@ public class EntityStateSourcingListener {
case CUSTOMER: case CUSTOMER:
case EDGE: case EDGE:
case NOTIFICATION_RULE: case NOTIFICATION_RULE:
case NOTIFICATION_REQUEST:
tbClusterService.broadcastEntityStateChangeEvent(tenantId, entityId, ComponentLifecycleEvent.DELETED); tbClusterService.broadcastEntityStateChangeEvent(tenantId, entityId, ComponentLifecycleEvent.DELETED);
break; break;
case RULE_CHAIN: case RULE_CHAIN:
@ -171,11 +172,6 @@ public class EntityStateSourcingListener {
TbResource tbResource = (TbResource) event.getEntity(); TbResource tbResource = (TbResource) event.getEntity();
tbClusterService.onResourceDeleted(tbResource, null); tbClusterService.onResourceDeleted(tbResource, null);
break; break;
case NOTIFICATION_REQUEST:
NotificationRequest request = (NotificationRequest) event.getEntity();
if (request.isScheduled()) {
tbClusterService.broadcastEntityStateChangeEvent(tenantId, entityId, ComponentLifecycleEvent.DELETED);
}
default: default:
break; break;
} }

4
application/src/main/java/org/thingsboard/server/service/notification/DefaultNotificationCenter.java

@ -398,10 +398,6 @@ public class DefaultNotificationCenter extends AbstractSubscriptionService imple
.notificationRequestId(notificationRequestId) .notificationRequestId(notificationRequestId)
.deleted(true) .deleted(true)
.build()); .build());
} else if (notificationRequest.isScheduled()) {
// TODO: just forward to scheduler service
// handling in EntityStateSourcingListener.class
// clusterService.broadcastEntityStateChangeEvent(tenantId, notificationRequestId, ComponentLifecycleEvent.DELETED);
} }
} }

4
dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationRequestService.java

@ -89,7 +89,9 @@ public class DefaultNotificationRequestService implements NotificationRequestSer
@Override @Override
public void deleteNotificationRequest(TenantId tenantId, NotificationRequest request) { public void deleteNotificationRequest(TenantId tenantId, NotificationRequest request) {
notificationRequestDao.removeById(tenantId, request.getUuidId()); notificationRequestDao.removeById(tenantId, request.getUuidId());
eventPublisher.publishEvent(DeleteEntityEvent.builder().tenantId(tenantId).entity(request).entityId(request.getId()).build()); if (request.isScheduled()) {
eventPublisher.publishEvent(DeleteEntityEvent.builder().tenantId(tenantId).entityId(request.getId()).build());
}
} }
@Override @Override

Loading…
Cancel
Save