How do I guarantee unique subscriptions in Orion Context Broker?

不想你离开。 提交于 2019-12-02 13:51:53

问题


In my setup I have one application that should subscribe to a specific kind of context change. The application currently perform subscription at startup time. However if I restart the application, the subscription is duplicated. To overcome this issue I started to keep track of subscriptions in a database, so that I have an association between my application id and the latest subscription id.

Is there any way to achieve similar result in Orion (let's call it like "named subscriptions"), without using an external database?


回答1:


There is a planned subscription "browsing" operation in Orion development roadmap (see operation ID 45 in this document) that could help in your case.

However, while this operation get implemented, one alternative to the one you mention (i.e. to keep subscription info in an external DB) would be to access to the Orion DB itself to get the subscription information. The datamodel (described here) is pretty simple and getting the info is quite easy if you are familiar with MongoDB. Note that this solution requires access to the Orion DB (i.e. it is feasible if you control your own instance of Orion).

EDIT: Given that different subscriptions may use the same reference, I'd recommend to use _id field to identify each subscription (_id field values are unique). NGSI doesn't include metadata in subscription, but you may associated subscription IDs with application using Orion itself, e.g. SubscriptionAssociation entities with two attributes, one for the application name and another for the subscription ID being associated

EDIT: since Orion 0.25.0, the GET /v2/subscriptions operation allows you to browse existing subscriptions.



来源:https://stackoverflow.com/questions/29782951/how-do-i-guarantee-unique-subscriptions-in-orion-context-broker

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!