-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Description
Part of #2782
The flow to create a Device Editor session involves the following initial steps (ref)
- An HTTP request is made to trigger the session
- An MQTT message is sent to the device to get it to connect
- The device connects its websocket
- The device published an MQTT message to confirm
- The HTTP request from the first step is completed with the session identifier.
The key point is that, in the above flow, the initial HTTP request is only responded to when a reply to the initial MQTT publish has been received over MQTT. In a scalable system, the Forge App will use a Shared Subscription to the broker - so that work can be distributed and will mean the reply could end up at a different instance.
The other place the command/response pattern is used is when the request to create a new Device Snapshot. The command is published and the device sends back the snapshot over MQTT. The original HTTP request to create the snapshot is blocked and only responds once the snapshot has been created.
Possible Solutions
-
Do not use a shared subscription for command/response MQTT pattern - and include a reply-to topic in the command message to ensure the response comes back to the topic subscribed to the correct instance.
- Cons
- Doesn't really solve the stateful nature of the command/response pattern
- The current Device Agent has a hardcoded response topic to use - so we'd have a legacy issue with existing devices.
- Cons
-
Redesign the whole command/response pattern to support stateless behaviour. The initial HTTP response will respond once the initial MQTT message is sent with some sort of 'pending' response including a request identifier. An API can then be used to track the completion of the pending request. The exact details of which will necessarily differ between the two current use-cases of the Command/Response pattern.
- Pros
- Cleanest solution that doesn't require any Device Agent changes
- Properly stateless
- Cons
- Not trivial to implement properly - needs some thought on database table structure.
- Changes the external API for settings up Device Editor and capturing Device Snapshot
- Pros
Epic/Story
Have you provided an initial effort estimate for this issue?
I have provided an initial effort estimate
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status