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 | 222 | } |
223 | 223 | } |
224 | 224 | return subscriptionUpdate; |
225 | - }); | |
225 | + }, true); | |
226 | 226 | if (entityId.getEntityType() == EntityType.DEVICE) { |
227 | 227 | updateDeviceInactivityTimeout(tenantId, entityId, ts); |
228 | 228 | } |
... | ... | @@ -256,7 +256,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene |
256 | 256 | } |
257 | 257 | } |
258 | 258 | return subscriptionUpdate; |
259 | - }); | |
259 | + }, true); | |
260 | 260 | if (entityId.getEntityType() == EntityType.DEVICE) { |
261 | 261 | if (TbAttributeSubscriptionScope.SERVER_SCOPE.name().equalsIgnoreCase(scope)) { |
262 | 262 | updateDeviceInactivityTimeout(tenantId, entityId, attributes); |
... | ... | @@ -333,14 +333,15 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene |
333 | 333 | } |
334 | 334 | } |
335 | 335 | return subscriptionUpdate; |
336 | - }); | |
336 | + }, false); | |
337 | 337 | callback.onSuccess(); |
338 | 338 | } |
339 | 339 | |
340 | 340 | private <T extends TbSubscription> void onLocalTelemetrySubUpdate(EntityId entityId, |
341 | 341 | Function<TbSubscription, T> castFunction, |
342 | 342 | Predicate<T> filterFunction, |
343 | - Function<T, List<TsKvEntry>> processFunction) { | |
343 | + Function<T, List<TsKvEntry>> processFunction, | |
344 | + boolean ignoreEmptyUpdates) { | |
344 | 345 | Set<TbSubscription> entitySubscriptions = subscriptionsByEntityId.get(entityId); |
345 | 346 | if (entitySubscriptions != null) { |
346 | 347 | entitySubscriptions.stream().map(castFunction).filter(Objects::nonNull).filter(filterFunction).forEach(s -> { |
... | ... | @@ -351,7 +352,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene |
351 | 352 | localSubscriptionService.onSubscriptionUpdate(s.getSessionId(), update, TbCallback.EMPTY); |
352 | 353 | } else { |
353 | 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 | 468 | } |
468 | 469 | |
469 | 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 | 475 | TbSubscriptionUpdateProto.Builder builder = TbSubscriptionUpdateProto.newBuilder(); |
471 | 476 | |
472 | 477 | builder.setSessionId(subscription.getSessionId()); |
... | ... | @@ -494,7 +499,7 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene |
494 | 499 | dataBuilder.addValue(strVal); |
495 | 500 | } |
496 | 501 | } |
497 | - if (hasData) { | |
502 | + if (!ignoreEmptyUpdates || hasData) { | |
498 | 503 | builder.addData(dataBuilder.build()); |
499 | 504 | } |
500 | 505 | }); | ... | ... |