1
votes

We are using the Orion Context Broker from a docker instance and we have found a possible unexpected behaviour:

If we request a subscription of a non-existent entity, instead of returning an error, the subscription is created.

Is this the expected behaviour?

You can replicate this issue by performing the following request:

curl -v localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' \
    -d @- <<EOF
{
  "description": "A subscription to a non-existent entity",
  "subject": {
    "entities": [
      {
        "id": "Non-existentEntity",
        "type": "Room"
      }
    ],
    "condition": {
      "attrs": [
        "pressure"
      ]
    }
  },
  "notification": {
    "http": {
      "url": "http://localhost:1028/accumulate"
    },
    "attrs": [
      "temperature"
    ]
  },
  "expires": "2040-01-01T14:00:00.00Z",
  "throttling": 5
}
EOF

You should receive a 201 created response with a Location header with the subscription. In our case we got:

< HTTP/1.1 201 Created
< Connection: Keep-Alive
< Content-Length: 0
< Location: /v2/subscriptions/5811cbdd88beb7a40eead166
< Fiware-Correlator: 952a13b6-9c29-11e6-a352-0242ac110003
< Date: Thu, 27 Oct 2016 09:41:49 GMT

You can check that the subscription was created retrieving all the subscriptions:

curl localhost:1026/v2/subscriptions

Or retrieving it directly by using the URI provided in the Location header. In our case:

curl localhost:1026/v2/subscriptions/5811cbdd88beb7a40eead166

We are using the following orion version:

{
  "orion" : {
  "version" : "1.4.0-next",
  "uptime" : "0 d, 0 h, 51 m, 21 s",
  "git_hash" : "f541d9282c8039dd46b5284a772ff956a16b9512",
  "compile_time" : "Thu Oct 20 07:51:10 UTC 2016",
  "compiled_by" : "root",
  "compiled_in" : "b99744612d0b"
}
}
1

1 Answers

0
votes

That is expected behaviour.

Subscriptions and entities are independent object. That means that you can create subscriptions that initially doesn't cover any entity, in the same way that deleting all the entities covered by a given subscritpion doesn't cause the subscription to be removed.

Note that it is a common use case create the subscription first as a kind of "bootstraping" of the system, then start running the client application implementing the the dynamics of entities creation.