Giulio Paci
Giulio Paci

Reputation: 303

How do I guarantee unique subscriptions in Orion Context Broker?

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?

Upvotes: 1

Views: 121

Answers (1)

fgalan
fgalan

Reputation: 12294

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.

Upvotes: 1

Related Questions