英文:
Conditional Requests on Connections
问题
我们在事物上有条件请求-HTTP API或Ditto协议标头。
是否有一种方法可以限制有效载荷发布到Ditto连接中的主题,除非匹配条件请求?
例如,在我的孪生中,我有一个名为“connectionState”的特性,其值为“Disconnected”。我想限制发布Ditto协议消息到一个主题,以在连接状态为Disconnected时更新其他特性。一旦连接状态变为“Connected”,我希望已发布的所有Ditto协议消息都可以更新所有其他特性。
Ditto连接是否有这样的条件请求?
英文:
We have conditional requests on things- HTTP API or Ditto Protocol headers.
Is there a way to restrict payload to get published into a topic in the ditto connections unless a conditional request is matched?
For example, in my twin I have a feature "connectionState" with value "Disconnected". I want to restrict publishing ditto protocol messages to a topic to update other features when the connectionState is Disconnected. Once the connectionState is "Connected", I want all the ditto protocol messages that have been published to update all the other features.
Is there such conditional request for ditto connections?
答案1
得分: 1
是的,可以配置如连接目标过滤器文档所述,并与请求额外字段一起使用。
例如:
{
"address": "<target-address>",
"topics": [
"_/_/things/twin/events?filter=ne(features/connectionState/properties/value,'Disconnected')&extraFields=features/connectionState/properties/value"
],
"authorizationContext": ["ditto:outbound-auth-subject", "..."]
}
这将仅在连接状态不是Disconnected时将孪生事件发布到目标地址。
英文:
Yes, that can be configured as documented for connection target filters
and in combination with requesting extraFields.
E.g.:
{
"address": "<target-address>",
"topics": [
"_/_/things/twin/events?filter=ne(features/connectionState/properties/value,'Disconnected')&extraFields=features/connectionState/properties/value"
],
"authorizationContext": ["ditto:outbound-auth-subject", "..."]
}
That will publish twin events to the target address only if the connectionState is not Disconnected.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论