【问题标题】:Fiware - Context broker: Issue with NGSIv2 subscriptionsFiware - 上下文代理:NGSIv2 订阅问题
【发布时间】:2023-04-01 00:05:01
【问题描述】:

我正在使用 Orion 上下文代理 1.2.0 版。我使用 NGSIv2 订阅了两个不同的 cygnus(0.11 和 0.13),如下:

(curl 172.21.0.23:1026/v2/subscriptions -s -S --header 'Fiware-Service: prueba_015_adapter' --header 'Fiware-ServicePath: /Prueba/Planta_3' --header 'Content-Type: application/json' -d @- ) <<EOF
{
    "description": "Cygnus subscription",
    "subject": {
        "entities": [
            {
                "idPattern": ".*",
                "type": "density_algorithm"
            }
        ],
        "condition": {
            "attrs": []
        }
    },
    "notification": {
        "http": {
            "url": "http://172.21.0.33:5050/notify"
        },
        "attrs": []
    }
}    
EOF

但是当上下文代理向任何这些 cygnus 模块发送通知时,日志中会出现下一个错误:

15 jun 2016 12:46:48,641 INFO  [1469152682@qtp-857344131-3153] (com.telefonica.iot.cygnus.handlers.OrionRestHandler.getEvents:150)  - Starting transaction (1463998603-759-0001644173) 15 jun 2016 12:46:48,641 INFO  [1469152682@qtp-857344131-3153] (com.telefonica.iot.cygnus.handlers.OrionRestHandler.getEvents:232)  - Received data ({"subscriptionId":"57612ed9efa20b5b23e71bd5","data":[{"id":"C-A2","type":"density_algorithm","densityPlan":{"type":"string","value":"C-A2","metadata":{}},"devices":{"type":"string","value":"43","metadata":{}},"timestamp":{"type":"string","value":"2016-06-15T12:53:26.294+02:00","metadata":{}}}]}) 15 jun 2016 12:46:48,641 INFO  [1469152682@qtp-857344131-3153] (com.telefonica.iot.cygnus.handlers.OrionRestHandler.getEvents:255)  - Event put in the channel (id=957931298, ttl=-1) 15 jun 2016 12:46:48,642 WARN  [1469152682@qtp-857344131-3153] (com.telefonica.iot.cygnus.interceptors.GroupingInterceptor.intercept:289)
- No context responses within the notified entity, nothing is done 15 jun 2016 12:46:48,642 WARN  [1469152682@qtp-857344131-3153] (org.apache.flume.source.http.HTTPSource$FlumeHTTPServlet.doPost:203) 
- Error appending event to channel. Channel might be full. Consider increasing the channel capacity or make sure the sinks perform faster. org.apache.flume.ChannelException: Unable to put batch on required channel: org.apache.flume.channel.MemoryChannel{name: mongo-channel}
        at org.apache.flume.channel.ChannelProcessor.processEventBatch(ChannelProcessor.java:200)
        at org.apache.flume.source.http.HTTPSource$FlumeHTTPServlet.doPost(HTTPSource.java:201)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:814)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Caused by: java.lang.IllegalArgumentException: put() called with null event!
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
        at org.apache.flume.channel.BasicTransactionSemantics.put(BasicTransactionSemantics.java:89)
        at org.apache.flume.channel.BasicChannelSemantics.put(BasicChannelSemantics.java:80)
        at org.apache.flume.channel.ChannelProcessor.processEventBatch(ChannelProcessor.java:189)
        ... 16 more

如果我使用 NGSIv1 来注册两个订阅,一切都会正常:不显示日志错误,并且数据会保存到两个 cygnus 模块中。

(curl 172.21.0.23:1026/v1/subscribeContext -s -S --header 'Fiware-Service: prueba_015_adapter' --header 'Fiware-ServicePath: /Prueba/Planta_3' --header 'Content-Type: application/json' --header 'Accept: application/json' -d  @- ) <<EOF
{
    "entities": [
        {
            "type": "density_algorithm",
            "isPattern": "true",
            "id": ".*"
        }
    ],
    "attributes": [],
    "reference": "http://172.21.0.33:5050/notify",
    "duration": "P1M",
    "notifyConditions": [
        {
            "type": "ONCHANGE",
            "condValues": []
        }
    ]
}
EOF

我正在使用 NGSIv1 将实体发送到上下文代理。问题可能是由于 NGSIv1 和 NGSIv2 不兼容造成的吗?

提前致谢

【问题讨论】:

    标签: fiware fiware-orion fiware-cygnus


    【解决方案1】:

    目前,Cygnus 不支持 NGSIv2 通知。是expected to be implemented,但还没有预定。

    但是,您可以使用等于legacyattrFormat(在nofitication 字段内)来使用NGSIv1 通知格式(查看更多详细信息here)。 Cygnus 完全支持 NGSIv1 通知格式,因此应该可以使用。

    【讨论】:

    • 答案与这个问题 stackoverflow.com/questions/37114255/why-cygnus-crashes-when-using-ngsiv2-in-orion 中的答案相似,也许你觉得这也很有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多