-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.4] Report device activity from edge service - set active flag to true on cloud #6684
[3.4] Report device activity from edge service - set active flag to true on cloud #6684
Conversation
TransportProtos.TransportToDeviceActorMsg msg = TransportProtos.TransportToDeviceActorMsg.newBuilder().setSessionInfo(sessionInfo) | ||
.setSubscriptionInfo(subscriptionInfoProto).build(); | ||
TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, tenantId, deviceId); | ||
tbCoreMsgProducer.send(tpi, new TbProtoQueueMsg<>(routingKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodymyr-babak, I am not sure that this is the best approach. Seems that registration of the session in the device actor is redundant and causes you to create a big unused object. If you just want to know the device's active/inactive state, you may "create" a new message to tb-core that will trigger:
systemContext.getDeviceStateService().onDeviceActivity(tenantId, deviceId, System.currentTimeMillis());
This will be easier and will consume much fewer resources. Because otherwise, you hardcode many values for the "fake" device session (like attribute and rpc subscriptions). However, if you do need this session to register in the device actor - the code changes are ok. Please provide your comments
@@ -96,6 +94,9 @@ public List<ListenableFuture<Void>> processTelemetryFromEdge(TenantId tenantId, | |||
if (entityData.hasPostTelemetryMsg()) { | |||
result.add(processPostTelemetry(tenantId, customerId, entityId, entityData.getPostTelemetryMsg(), metaData)); | |||
} | |||
if (EntityType.DEVICE.equals(entityId.getEntityType())) { | |||
deviceStateService.onDeviceActivity(tenantId, new DeviceId(entityId.getId()), System.currentTimeMillis()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send this via kafka to the correct node. But add a new message to trigger this code in TbCoreConsumer
Pull Request description
Added report activity functionality for edge sessions to notify device state service and set a correctly 'active' flag on devices.
Related issue - thingsboard/thingsboard-edge#8
General checklist
Back-End feature checklist