hono icon indicating copy to clipboard operation
hono copied to clipboard

Command Router: close tenant-scoped links when not needed anymore

Open calohmn opened this issue 5 years ago • 2 comments

The Command Router component creates tenant-scoped command consumer links. With the old command & control handling in the protocol adapters, such links were closed when not needed anymore using the tenant-timeout mechanism (#1188/#1475). In the Command Router component, the tenant-scoped links are currently not getting closed.

Applying an adapted tenant-timeout mechanism is probably difficult. When closing a link, we would have to make sure that in the protocol adapters all command consumer connections are closed as well. Otherwise there could be devices still waiting for commands but not being able to get them until a device subscribes for commands again.

A solution could be using the Device Connection cache data. If no commands (or new subscriptions) for a tenant have been received for some time, the Command Router instance queries the cache for the tenant/device-to-protocolAdapterInstance entries belonging to that tenant. If there are none, the tenant-scoped link can be closed.

calohmn avatar Dec 08 '20 17:12 calohmn

One kind of obsolete links could be closed by reacting on "Tenant deleted/disabled" notification messages .

calohmn avatar Jun 03 '22 11:06 calohmn

One kind of obsolete links could be closed by reacting on "Tenant deleted/disabled" notification messages .

Is this already implemented?

sophokles73 avatar Jun 13 '22 13:06 sophokles73

Is this already implemented?

No, reacting on "Tenant deleted/disabled" (and "all devices of tenant deleted") notification messages in the Command Router isn't implemented yet. This would be straightforward to implement.

I think we can limit this issue here to that. Implementing some kind of tenant-idle check using Device Connection cache data seems quite complex.

calohmn avatar Aug 19 '22 08:08 calohmn

I would like to work on this issue.

kduba avatar Aug 19 '22 10:08 kduba

Resolved via #3387.

calohmn avatar Aug 23 '22 08:08 calohmn