2
votes

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

1

1 Answers

2
votes

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.