发布后订阅状态更改 [英] Subscription status change after post

查看:110
本文介绍了发布后订阅状态更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

成功安装Cygnus连接器并测试订阅的创建后.

After successfully installed Cygnus connector and testing the creation of subscriptions.

具有波纹管文件:

agent_1.conf

cygnus-ngsi.sources = http-source
cygnus-ngsi.sinks = hdfs-sink
cygnus-ngsi.channels = hdfs-channel

cygnus-ngsi.sources.http-source.type = org.apache.flume.source.http.HTTPSource
cygnus-ngsi.sources.http-source.channels = hdfs-channel
cygnus-ngsi.sources.http-source.port = 5050
cygnus-ngsi.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.NGSIRestHandler
cygnus-ngsi.sources.http-source.handler.notification_target = /notify
cygnus-ngsi.sources.http-source.handler.default_service = [ PERSONALIZED SERVICE NAME ]
cygnus-ngsi.sources.http-source.handler.default_service_path = /[ PERSONAL SERVICE PATH ]
cygnus-ngsi.sources.http-source.handler.events_ttl = 10
cygnus-ngsi.sources.http-source.interceptors = ts gi
cygnus-ngsi.sources.http-source.interceptors.ts.type = timestamp
cygnus-ngsi.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.NGSIGroupingInterceptor$Builder
cygnus-ngsi.sources.http-source.interceptors.gi.grouping_rules_conf_file = /usr/cygnus/conf/grouping_rules.conf

cygnus-ngsi.sinks.hdfs-sink.type = com.telefonica.iot.cygnus.sinks.NGSIHDFSSink
cygnus-ngsi.sinks.hdfs-sink.channel = hdfs-channel
cygnus-ngsi.sinks.hdfs-sink.hdfs_host = storage.cosmos.lab.fiware.org
cygnus-ngsi.sinks.hdfs-sink.hdfs_port = 14000
cygnus-ngsi.sinks.hdfs-sink.hdfs_username = [ MY USERNAME ]
cygnus-ngsi.sinks.hdfs-sink.oauth2_token = [ MY TOKEN ]


cygnus-ngsi.channels.hdfs-channel.type = com.telefonica.iot.cygnus.channels.CygnusMemoryChannel
cygnus-ngsi.channels.hdfs-channel.capacity = 1000
cygnus-ngsi.channels.hdfs-channel.transactionCapacity = 100

cygnus_interface_1.conf

CYGNUS_USER=cygnus
CONFIG_FOLDER=/usr/cygnus/conf
CONFIG_FILE=/usr/cygnus/conf/agent_1.conf
AGENT_NAME=cygnus-ngsi
LOGFILE_NAME=cygnus.log
ADMIN_PORT=8081
POLLING_INTERVAL=30

使用NGSI V1测试

我尝试创建如下所示的订阅:

TESTING WITH NGSI V1

I have tried creating a subscription as presented below:

[POST]

http://[ MY ORION IP ]:1026/v1/subscribeContext

[标头]

Content-Type:application/json
Accept: application/json
Fiware-Service: [ PERSONALIZED SERVICE NAME ]
Fiware-ServicePath: /[ PERSONALIZED PATH ]

[身体]

{
    "entities": [
        {
            "type": "PhysicalTest",
            "isPattern": "false",
            "id": "TEMPORAL"
        }
    ],
    "attributes": [
        "test"
    ],
    "reference": "http://localhost:5050/notify",
    "duration": "P1M",
    "notifyConditions": [
        {
            "type": "ONCHANGE",
            "condValues": [
                "test"
            ]
        }
    ],
    "throttling": "PT1S"
}

使用NGSI V2测试

我还尝试过创建如下所示的订阅:

TESTING WITH NGSI V2

I also have tried creating a subscription as presented below:

[POST]

http://[ MY ORION IP ]:1026/v2/subscriptions

[标头]

Content-Type:application/json
Accept: application/json
Fiware-Service: [ PERSONALIZED SERVICE NAME ]
Fiware-ServicePath: /[ PERSONALIZED PATH ]

[身体]

{
  "description": "Subscription to store physical tests",
  "subject": {
    "entities": [
      {
        "type": "PhysicalTest",
        "isPattern": "false",
        "id": "TEMPORAL"
      }
    ],
    "condition": {
      "attrs": [
        "test"
      ],
      "expression": {
        "q": "test!=0"
      }
    }
  },
  "notification": {
    "http": {
      "url": "http://localhost:5050/notify"
    },
    "attrs": [
      "test"
    ]
  },
  "expires": "2018-04-05T14:00:00.00Z",
  "throttling": 5
}

在检查先前创建的订阅时.我发现它带有:"status":"active";太好了

When checking previously created subscription. I found it with: "status": "active"; which is great.

在两种类型的订阅中(即通过v1和v2),我都会发布如下信息:

In both type of subscriptions (i.e., through v1 and v2) I post as showed below:

[POST]

http://[ MY ORION IP ]:1026/v2/entities

[标头]

Content-Type:application/json
Accept: application/json
Fiware-Service: [ PERSONALIZED SERVICE NAME ]
Fiware-ServicePath: /[ PERSONALIZED PATH ]

[身体]

{
    "id": "TEMPORAL",
    "type": "PhysicalTest",
    "test": {
        "value": "Timed Up and Go",
        "type": "test-type"
        },
    "sensor": {
        "value": "Accelerometer",
        "type": "sensor-type",
        "metadata": {
            "speed": {
                "value": "80",
                "type": "hz"
                }
            }
        },
    "data": {
        "value": "0.0635477304458618,0.00490868091583252,0.0516815185546875,2016-09-08T10:51:41.341Z-0500",
        "type": "sensor-data"
        }
}

失败结果

在两种情况下我的订阅状态转到:状态":失败"

此外,没有证据表明Cosmos在查看应存储实体文件的目录时正在存储任何内容:

Moreover, there is no evidence of that Cosmos is storing anything while looking at the directories where entity files should be stored:

curl -X GET "http://storage.cosmos.lab.fiware.org:14000/webhdfs/v1/user/[ MY USERNAME ]?op=liststatus&user.name=[ MY USERNAME ]" -H "X-Auth-Token: [ MY TOKEN ]" | python -m json.tool

只是为了记录

我已经通过以下方式成功测试了Cygnus连接:

JUST FOR THE RECORD

I have already successfully tested the Cygnus connection by:

./notification-json-simple.sh http://localhost:5050/notify 

因此,我认为它们可能与我的订阅机制有关,但仍然找不到毛病.

Thus, I presume they might be something with my subscription mechanism, but still cannot find the glitch.

.
.
.
time=Sunday 29 Jan 19:41:07 2017.697Z | lvl=WARN | corr=N/A | trans=1485717075-957-00000000006 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=AlarmManager.cpp[328]:notificationError | msg=Raising alarm NotificationError localhost:5050/notify: (curl_easy_perform failed: Couldn't connect to server)

有解决这个问题的提示吗?

Any hint to solve this?

推荐答案

显然,所有内容都与通知引用有关.通过更改相应IP地址的本地主机,我的订阅将在发布任何内容后保持有效(即保持状态":活动").我还测试了成功从Orion到Cosmos通知/触发从Orion到第三方服务器的通知.

Apparently everything was about the notification reference. By changing localhost for respective IP address, my subscription keeps alive (i.e., keeping "status": "active") after any post. I have also tested notifying/triggering a notification from Orion to a third party server successfully as well as Cosmos.

这篇关于发布后订阅状态更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆