2

I'm reading the documentation about OCB subscriptions I don't find anything. Only a Python example, called accumulator.py (and I don't know Python :(, I'm Java developer ). I refer to the notifications that Orion sent as a consequence of subscriptions, the services that you can indicate in the attribute reference

Is it a GET service or POST? Does it need any parameter? I'm writing a REST GET service with a param, that is the JSON string that Orion Context Broker must send me to update my application. Is it correct??

Can you help me, please?

Thanks in advance

jjmartinez
  • 779
  • 5
  • 20
  • 37

1 Answers1

2

I would recommend you to have a look to the Orion Context Broker User Manual, where all the information about HTTP verbs, operation URLs and parameters is provided.

UPDATE: regarding notifications sent by Orion, the manual includes some examples, as this one:

POST http://localhost:1028/accumulate
Content-Length: 492
User-Agent: orion/0.9.0
Host: localhost:1028
Accept: application/xml, application/json
Content-Type: application/json

{
  "subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
  "originator" : "localhost",
  "contextResponses" : [
    {
      "contextElement" : {
        "attributes" : [
          {
            "name" : "temperature",
            "type" : "float",
            "value" : "26.5"
          }
        ],
        "type" : "Room",
        "isPattern" : "false",
        "id" : "Room1"
      },
      "statusCode" : {
        "code" : "200",
        "reasonPhrase" : "OK"
      }
    }
  ]
}

As you can see in the fragment above, the verb used is POST (not GET). Thus, you should prepare your code listening for notifications to receive POST requests in the right URL (in this example the URL is /accumulate) and process the payload in the way you need depending your application.

For example, in Python you can use a decorator (using Flask framework):

@app.route('/accumulate', methods=['POST'])
def process_notification():
    # Do whatever you want with the request payload

I don't know how REST server programming works in Java, but I guess that a similar approach would be possible.

fgalan
  • 11,732
  • 9
  • 46
  • 89
  • The manual is not clear for me in this aspect. This is the only phrase that I see regarding subscription service :( "Orion Context Broker notifies NGSI10 subscribeContext using the POST HTTP method (on the URL used as reference for the subscription) with a notifyContextRequest payload. Apart from the subscriptionId element (that matches the one in the response to subscribeContext request) and the originator element, there is a contextResponseList element which is the same that the one used in the queryContext responses"" – jjmartinez Apr 01 '15 at 11:38
  • 1
    I'm a bit confused... do you refer to the *subscription* operations that Orion API clients implement in order to create and manage subscriptions? Or do you refer to the *notifications* that Orion sent (as a consequence of subscriptions)? Please, try to be clear in your question text (you can edit it). In addition, try to be as detailed as you can in your questions, in order we can provide precise answers. Thanks! – fgalan Apr 01 '15 at 11:43