【问题标题】:Subscription doesn't appear although success is reported尽管报告成功,但未显示订阅
【发布时间】:2015-01-26 09:12:31
【问题描述】:

我正在尝试为 OrionCB 中现有实体的属性创建订阅。

网址 http://130.206.80.120:1026/NGSI10/subscribeContext

方法 发布

标题 内容类型:application/xml

身体

<?xml version="1.0"?>
<subscribeContextRequest>
  <entityIdList>
    <entityId type="finesce_meteo" isPattern="false">
      <id>finesce_meteo</id>
    </entityId>
  </entityIdList>
  <attributeList>
    <attribute>precip</attribute>
  </attributeList>
  <reference>http://localhost:5050/notify</reference>
  <duration>P100Y</duration>
  <notifyConditions>
    <notifyCondition>
      <type>ONCHANGE</type>
      <condValueList>
        <condValue>precip</condValue>
      </condValueList>
    </notifyCondition>
  </notifyConditions>
  <throttling>PT5S</throttling>
</subscribeContextRequest>

此操作检索 200 个 OK 标头代码,带有以下正文:

<subscribeContextResponse>
  <subscribeResponse>
    <subscriptionId>54c5f049286043784451d08b</subscriptionId>
    <duration>P100Y</duration>
    <throttling>PT5S</throttling>
  </subscribeResponse>
</subscribeContextResponse>

问题是当我尝试检查它是否已创建时。当我尝试列出订阅时,它不会出现。我正在使用这条线:

echo 'db.csubs.find().pretty()' | mongo orion

但是如果我用 unsubscribeContextRequest 删除这个订阅,我会得到 200 OK 代码。它表明此订阅存在。

订阅存在(因为它创建和删除都正常),并且在我列出订阅的任何时候都没有出现,这种情况很少见。

请问有什么问题吗?

我正在尝试启动这个 whit cygnus 进程,然后停止与 cygnus 相同的进程,获得相同的结果。

问候

【问题讨论】:

  • 请编辑您的问题以显示启动 Orion Context Broker 的命令行,通常是 ps ax | grep contextBroker 命令的结果。
  • [root@orioncb ~]# ps ax | grep contextBroker 6889 pts/1 S+ 0:00 grep contextBroker 28707 ? Ssl 672:56 /usr/bin/contextBroker -port 1026 -logDir /var/log/contextBroker -pidpath /var/log/contextBroker/contextBroker.pid -dbhost localhost -db orion

标签: mongodb fiware fiware-orion fiware-cygnus


【解决方案1】:

Mongo find() 命令返回与查询匹配的前 20 个结果,因此,如果您的订阅数多于该数(例如超过 30 个),则可能无法检索到您正在搜索的特定结果。 (使用 mongo 交互式 shell,您可以使用 it 命令获得下一批 20 个结果,但不确定当 mongo 在非交互模式下运行时这是如何工作的)。

因此,我建议您在查询中包含要搜索的 ID。例如,如果您在 Orion 请求中获得的 id 是“54c90821286043500575eecf”,那么您可以使用:

echo 'db.csubs.find({_id: ObjectId("54c90821286043500575eecf")}).pretty()' | mongo orion

Morevoer,由于您只期望一个结果,您可以使用findOne() 并保存pretty() 的用法,即:

echo 'db.csubs.findOne({_id: ObjectId("54c90821286043500575eecf")})' | mongo orion

【讨论】:

    猜你喜欢
    • 2019-02-20
    • 1970-01-01
    • 2015-11-15
    • 2017-08-28
    • 1970-01-01
    • 1970-01-01
    • 2013-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多