JosepB
JosepB

Reputation: 2315

Send Orion Context Broker 0.13.0 entities to Cosmos using Cygnus

I'm using Cygnus to send data to cosmos. When there's a entity subscription to the context broker, in the JSON message you have to specify the event or trigger when the attribute of the entity have to be updated or sent to Cygnus. In the Cygnus documentation appears the following link:

https://forge.fi-ware.eu/plugins/mediawiki/wiki/fiware/index.php/Publish/Subscribe_Broker_-_Orion_Context_Broker_-_User_and_Programmers_Guide#ONCHANGE

It works in the release 0.13.0 of the Orion Context Broker?

First you have to create the entity and then create the notification? Or can you create the entity subscription and the notification in the same JSON message?

Can I see an example in JSON?

Upvotes: 3

Views: 565

Answers (1)

fgalan
fgalan

Reputation: 12322

The general subscription/notification mechanism works with Cygnus in Orion 0.13.0 (and, in general, in any version, except maybe very ancient ones). The procedure will be, in general terms, assuming you have the Orion and Cygnus instances properly configured and running:

First, create a subscription at Orion, using as reference the host/port in which Cygnus is listening to. Example subscription:

{
"entities": [
    {
        "type": "Room",
        "isPattern": "false",
        "id": "Room1"
    }
],
"attributes": [ ],
"reference": "cygnus_host:cygnus_port/cygnus_url",
"duration": "P1M",
"notifyConditions": [
    {
        "type": "ONCHANGE",
        "condValues": [
            "pressure",
            "temperature"
        ]
    }
]
}

Second, update at Orion any of the entity attributes at condValues in the subscription. Considering the above example, updates in "pressure" or "temperature" would case notifications. E.g. update on temperature:

{
"contextElements": [
    {
        "type": "Room",
        "isPattern": "false",
        "id": "Room1",
        "attributes": [
        {
            "name": "temperature",
            "type": "centigrade",
            "value": "26.5"
        }
        ]
    }
]
}

Finally, the above update will cause a notification being sent to Cygnus with in sequence will persit in on the configured sink(s), e.g. Cosmos BigData, MySQL (from Cygnus 0.2.1) or CKAN (from Cygnus 0.3).

Additional observations:

  • The notification may include all the attributes of the entity or a subset of them. In addition, you can subscribe to particular entities or to groups using entity patterns. Check Orion Context broker notifications documentation for details.
  • The cygnus_port above must match with the value of the parameter cygnusagent.sources.http-source.port in Cygnus configuration
  • The cygnus_url above must match with the value of the parameter cygnusagent.sources.http-source.handler.notification_target in Cygnus
  • If you are using Cygnus 0.2.1 or older, the value of cygnusagent.sources.http-source.handler.orion_version must match the version of Orion you are using (Cygnus 0.3 will not use any longer this mechanism).

Please, have a look to Cygnus documentation for more details.

(NOTE: Include http:// before the reference element, I cannot add it myself due to StackOverFlow editing limitations)

Upvotes: 2

Related Questions