Comments (3)
- Device real status will managed by
DeviceSessionManager
in memory. - When device register to
DeviceSessionManager
, devicestate
,server id
will save toDeviceRegistry
(Redis). - Publish
DeviceOnlineMessage
toEventBus
/device/{productId}/{deviceId}/online
. DeviceMessageBusinessHandler
subscribe topic/device/*/*/online,offline
fromEventBus
when server started.- Synchronization device real state to
PostgreSQL
whenEventBus
sent/device/*/*/online,offline
message ,( getstate
from DeviceRegsitry ) - Check real state when api request:
/device/instance/{deviceId}/detail
and synchronization it.
from jetlinks-community.
- When device register to
DeviceSessionManager
, devicestate
,server id
will save toDeviceRegistry
(Redis).
In fact, Redis can not keep real-time for device state:
e.g. When the service restarts or crashes, the state does not have time to synchronize.
JetLinks device state check strategy :
- Get
server id
info inDeviceRegistry
(store in redis, cache in memory.). - RPC the
server id
: Get device real state. - If cached
state
not equals RPC response, synchronization toPostgreSQL
TIP: The same principle was used in a send device message (when cluster).
from jetlinks-community.
- Device real status will managed by
DeviceSessionManager
in memory.- When device register to
DeviceSessionManager
, devicestate
,server id
will save toDeviceRegistry
(Redis).- Publish
DeviceOnlineMessage
toEventBus
/device/{productId}/{deviceId}/online
.DeviceMessageBusinessHandler
subscribe topic/device/*/*/online,offline
fromEventBus
when server started.- Synchronization device real state to
PostgreSQL
whenEventBus
sent/device/*/*/online,offline
message ,( getstate
from DeviceRegsitry )- Check real state when api request:
/device/instance/{deviceId}/detail
and synchronization it.
Thank you for your answer, but I still have a question:
Is it not quite appropriate to store the real state of the device in memory? This is not conducive to horizontal scaling. Perhaps it would be better to use Redis' ZSET to store the device ID and use the device's last active time as its score?
from jetlinks-community.
Related Issues (20)
- 社区版怎么扩展对其他数据库的支持 HOT 1
- 使用高级查询 ,后端使用sql左连接方式报错 HOT 8
- 图片上传是在哪里http://localhost:5173/api/file/static HOT 1
- queryHelper leftJoin 失效 HOT 3
- 通知模板里的收件人如果不填会报错 HOT 5
- 新拉master分支代码,ES报错服务起不来 HOT 2
- 企业微服务版本使用docker容器化部署之后 文件服务有问题 HOT 17
- 轮询产品设有多属性的BUG HOT 9
- mqtt上来的消息在哪个类里面处理的?
- common-component IntervalUnit 中 写死UTC时区是什么原因 可否修改呢? HOT 3
- 优化: 多参数轮询流控操作 HOT 2
- hswebframework相关的包拉不下来 HOT 1
- 数据库表 HOT 1
- 如何在jetlinks 不使用响应式的r2dbc 而同时接入jdbc 完成对报表类的需求的开发等等 HOT 13
- BUG反馈,当前后端代码和前端代码版本不一致!后端2.1版本缺失前端2.1版本对应的接口 HOT 1
- queryHelper 直接查询语句映射问题 HOT 3
- tcp拆包问题 HOT 6
- 请教下AggregationService ElasticSearchService 这两个类如何使用 有相关文档吗 HOT 1
- 请教下repository 可以在创建sql的时候就进行sql的group by吗 HOT 5
- 系统初始化失败
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jetlinks-community.