简体   繁体   English

Orion Context Broker Fiware中订阅的属性参考

[英]Attribute Reference for subscription in Orion Context Broker Fiware

What do I need to put in the reference attribute? 我需要在引用属性中添加什么?

I'm using two forms, and the two are bad for Orion Context Broker : 我使用两种形式,这两种形式对Orion Context Broker都是不利的:

URL url = new URL("http://130.206.127.23:1026/ngsi10/notifyContext");
//String url = "http://localhost:1028/accumulate";
cabecera.put("reference", ""+url);

With this code, I'm generating the next JSON String for the reference attribute 使用此代码,我将为reference属性生成下一个JSON String

...."reference":"http:\/\/130.206.127.23:1026\/ngsi10\/notifyContext",...

And this is the response of OCB 这是OCB的回应

<subscribeContextResponse>
  <subscribeError>
    <errorCode>
      <code>400</code>
      <reasonPhrase>Bad Request</reasonPhrase>
      <details>JSON Parse Error: <unspecified file>(1): invalid escape sequence</details>
    </errorCode>
  </subscribeError>
</subscribeContextResponse>

Also related to this parameter,do I need a program in execution in a server to receive the information about my subscription? 也与此参数有关,我是否需要服务器中正在执行的程序来接收有关我的订阅的信息?
Can I get a program from Orion Context Broker resources to do this task? 我可以从Orion Context Broker资源中获取程序来执行此任务吗?

The following is my JSON to call the service, but I'm not sure about the reference attribute. 以下是我调用服务的JSON,但是我不确定reference属性。 I want to send a subscription to my Orion Context Broker instance. 我想向我的Orion Context Broker实例发送订阅。 I'm sending this JSON: 我正在发送此JSON:

{
  "duration": "P1M",
  "reference": "http://130.206.127.23:1026/ngsi10/notifyContext",
  "notifyConditions": [
    {
      "condValues": [
        "PT10s"
      ],
      "type": "ONTIMEINTERVAL"
    }
  ],
  "entities": [
    {
      "id": "1.0",
      "type": "Capsule",
      "isPattern": "false"
    }
  ],
  "attributes": [
    "temperature"
  ]
}

Thanks in advance. 提前致谢。

The reference element is described in the Orion User Manual : 参考元素在Orion用户手册中进行描述:

The callback URL to send notifications is defined with the reference element. 发送通知的回调URL是使用reference元素定义的。

Thus, if your reference is http://130.206.127.23:1026/ngsi10/notifyContext as shown in your example, you should have a REST server listening at host 130.206.127.23 port 1026, able to receive notifications in the /ngsi10/notifyContext path. 因此,如您的示例所示,如果您的引用是http://130.206.127.23:1026/ngsi10/notifyContext ,则您应该在主机130.206.127.23端口1026上侦听REST服务器,以便能够在/ngsi10/notifyContext接收通知路径。 Note that your CB (I mean, the one to which you are sending the subscribeContext request) is the actor that sends notification, not the actor that receives them, so it must not run at 130.206.127.23:1026. 请注意,您的CB(我的意思是,您要向其发送subscriptionContext请求的CB)是发送通知的参与者,而不是接收通知的参与者,因此它不得运行在130.206.127.23:1026。

You can implement the notifications receiver program in any programming language that you want (as long as it implements the required REST server interface). 您可以使用所需的任何编程语言来实现Notifications Receiver程序(只要它实现了所需的REST服务器接口)。 You can have a look to the accumulator-server.py , which is a "dummy" notification receiver example implemented in Python, used for testing. 您可以看一下accumulator-server.py ,这是用Python实现的“虚拟”通知接收器示例,用于测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM