Commit 1298f6b13047627e9199e2812ef5b7221fba1910
1 parent
26d18724
Fix delete attributes cluster notification
Showing
1 changed file
with
11 additions
and
6 deletions
@@ -222,7 +222,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | @@ -222,7 +222,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | ||
222 | } | 222 | } |
223 | } | 223 | } |
224 | return subscriptionUpdate; | 224 | return subscriptionUpdate; |
225 | - }); | 225 | + }, true); |
226 | if (entityId.getEntityType() == EntityType.DEVICE) { | 226 | if (entityId.getEntityType() == EntityType.DEVICE) { |
227 | updateDeviceInactivityTimeout(tenantId, entityId, ts); | 227 | updateDeviceInactivityTimeout(tenantId, entityId, ts); |
228 | } | 228 | } |
@@ -256,7 +256,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | @@ -256,7 +256,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | ||
256 | } | 256 | } |
257 | } | 257 | } |
258 | return subscriptionUpdate; | 258 | return subscriptionUpdate; |
259 | - }); | 259 | + }, true); |
260 | if (entityId.getEntityType() == EntityType.DEVICE) { | 260 | if (entityId.getEntityType() == EntityType.DEVICE) { |
261 | if (TbAttributeSubscriptionScope.SERVER_SCOPE.name().equalsIgnoreCase(scope)) { | 261 | if (TbAttributeSubscriptionScope.SERVER_SCOPE.name().equalsIgnoreCase(scope)) { |
262 | updateDeviceInactivityTimeout(tenantId, entityId, attributes); | 262 | updateDeviceInactivityTimeout(tenantId, entityId, attributes); |
@@ -333,14 +333,15 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | @@ -333,14 +333,15 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | ||
333 | } | 333 | } |
334 | } | 334 | } |
335 | return subscriptionUpdate; | 335 | return subscriptionUpdate; |
336 | - }); | 336 | + }, false); |
337 | callback.onSuccess(); | 337 | callback.onSuccess(); |
338 | } | 338 | } |
339 | 339 | ||
340 | private <T extends TbSubscription> void onLocalTelemetrySubUpdate(EntityId entityId, | 340 | private <T extends TbSubscription> void onLocalTelemetrySubUpdate(EntityId entityId, |
341 | Function<TbSubscription, T> castFunction, | 341 | Function<TbSubscription, T> castFunction, |
342 | Predicate<T> filterFunction, | 342 | Predicate<T> filterFunction, |
343 | - Function<T, List<TsKvEntry>> processFunction) { | 343 | + Function<T, List<TsKvEntry>> processFunction, |
344 | + boolean ignoreEmptyUpdates) { | ||
344 | Set<TbSubscription> entitySubscriptions = subscriptionsByEntityId.get(entityId); | 345 | Set<TbSubscription> entitySubscriptions = subscriptionsByEntityId.get(entityId); |
345 | if (entitySubscriptions != null) { | 346 | if (entitySubscriptions != null) { |
346 | entitySubscriptions.stream().map(castFunction).filter(Objects::nonNull).filter(filterFunction).forEach(s -> { | 347 | entitySubscriptions.stream().map(castFunction).filter(Objects::nonNull).filter(filterFunction).forEach(s -> { |
@@ -351,7 +352,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | @@ -351,7 +352,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | ||
351 | localSubscriptionService.onSubscriptionUpdate(s.getSessionId(), update, TbCallback.EMPTY); | 352 | localSubscriptionService.onSubscriptionUpdate(s.getSessionId(), update, TbCallback.EMPTY); |
352 | } else { | 353 | } else { |
353 | TopicPartitionInfo tpi = partitionService.getNotificationsTopic(ServiceType.TB_CORE, s.getServiceId()); | 354 | TopicPartitionInfo tpi = partitionService.getNotificationsTopic(ServiceType.TB_CORE, s.getServiceId()); |
354 | - toCoreNotificationsProducer.send(tpi, toProto(s, subscriptionUpdate), null); | 355 | + toCoreNotificationsProducer.send(tpi, toProto(s, subscriptionUpdate, ignoreEmptyUpdates), null); |
355 | } | 356 | } |
356 | } | 357 | } |
357 | }); | 358 | }); |
@@ -467,6 +468,10 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | @@ -467,6 +468,10 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | ||
467 | } | 468 | } |
468 | 469 | ||
469 | private TbProtoQueueMsg<ToCoreNotificationMsg> toProto(TbSubscription subscription, List<TsKvEntry> updates) { | 470 | private TbProtoQueueMsg<ToCoreNotificationMsg> toProto(TbSubscription subscription, List<TsKvEntry> updates) { |
471 | + return toProto(subscription, updates, true); | ||
472 | + } | ||
473 | + | ||
474 | + private TbProtoQueueMsg<ToCoreNotificationMsg> toProto(TbSubscription subscription, List<TsKvEntry> updates, boolean ignoreEmptyUpdates) { | ||
470 | TbSubscriptionUpdateProto.Builder builder = TbSubscriptionUpdateProto.newBuilder(); | 475 | TbSubscriptionUpdateProto.Builder builder = TbSubscriptionUpdateProto.newBuilder(); |
471 | 476 | ||
472 | builder.setSessionId(subscription.getSessionId()); | 477 | builder.setSessionId(subscription.getSessionId()); |
@@ -494,7 +499,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | @@ -494,7 +499,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene | ||
494 | dataBuilder.addValue(strVal); | 499 | dataBuilder.addValue(strVal); |
495 | } | 500 | } |
496 | } | 501 | } |
497 | - if (hasData) { | 502 | + if (!ignoreEmptyUpdates || hasData) { |
498 | builder.addData(dataBuilder.build()); | 503 | builder.addData(dataBuilder.build()); |
499 | } | 504 | } |
500 | }); | 505 | }); |