Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-8997

[fiware-stackoverflow] How to make an Orion NGSIv2 subscription that notifies cygnus in NGSIv1?

    Details

      Description

      Created question in FIWARE Q/A platform on 17-05-2016 at 15:05
      Please, ANSWER this question AT https://stackoverflow.com/questions/37277048/how-to-make-an-orion-ngsiv2-subscription-that-notifies-cygnus-in-ngsiv1

      Question:
      How to make an Orion NGSIv2 subscription that notifies cygnus in NGSIv1?

      Description:
      EDIT 2

      curl --include \
      --header 'Content-Type: application/json' \
      --request POST \
      --data-binary '{
      "description": "Day subscription",
      "subject": {
      "entities": [

      { "idPattern": "es-leon-.*", "type": "Event" }

      ],
      "condition": {
      "attrs": [
      "Title",
      "dFlag"
      ],
      "expression":

      { "q": "dFlag>0" }

      }
      },
      "notification": {
      "http":

      { "url" : "http://localhost:5050/notify" }

      ,
      "attrs": [
      "Title",
      "dFlag"
      ],
      "attrsFormat":"legacy"
      }
      }' \
      'http://localhost:1026/v2/subscriptions'

      In Orion the subscription register ok (thanks for the tips in the comments) but I'm having the same issue as said in here even though I use "attrsFormat":"legacy"
      I'm making something wrong? why orion is not using ngsiv1 to send the notification to cygnus?

      The cygnus error trace.

      Cygnus shows orion is responding this:

      {
      "subscriptionId": "574315e77775f31b8d3da719",
      "data": [{
      "id": "es-leon-0",
      "type": "Event",
      "Title": {
      "type": "none",
      "value": "pepe",
      "metadata": {}
      },
      "dFlag": {
      "type": "text",
      "value": "1",
      "metadata": {}
      }
      }]
      }

      When it has to respond the lines below to be in ngsiv1:

      {
      "subscriptionId": "5743178d7775f31b8d3da71a",
      "originator": "localhost",
      "contextResponses": [{
      "contextElement": {
      "type": "Event",
      "isPattern": "false",
      "id": "es-leon-0",
      "attributes": [

      { "name": "Title", "type": "text", "value": "pep" }

      ,

      { "name": "dFlag", "type": "text", "value": "1" }

      ]
      },
      "statusCode":

      { "code": "200", "reasonPhrase": "OK" }

      }]
      }

      Original Question

      As said in other question :

      EDIT: note also that you can use NGSIv2 to create/update entities at
      Orion and have notifications in NGSIv1 if you:

      Create the subscription using NGSIv1 operations

      Create the subscription using NGSIv2 operations with attrsFormat equal to legacy.
      Have a look to more detailed information here.

      So I made up this subscription:

      curl --include \
      --header 'Content-Type: application/json' \
      --request POST \
      --data-binary '{
      "description": "Day subscription",
      "subject": {
      "entities": [

      { "idPattern": "es-leon-.*", "type": "Event" }

      ],
      "condition": {
      "attributes": [
      "Title",
      "dFlag"
      ],
      "expression":

      { "q": "dFlag > 0" }

      }
      },
      "notification":

      { "callback": "http://localhost:5050/notify", "attributes": [ "Title", "dFlag" ] }

      }' \
      'http://localhost:1026/v1/subscriptions'

      but orion don't let me register it throwing this error:

      HTTP/1.1 400 Bad Request
      Connection: Keep-Alive
      Content-Length: 67
      Content-Type: application/json
      Fiware-Correlator: 2ecdfc74-1c2f-11e6-82d7-000d3a23bf27
      Date: Tue, 17 May 2016 12:59:25 GMT

      {"error":"BadRequest","description":"no condition attrs specified"}

      Is this the way to use legacy attributes so it can work with cygnus with NGSIv2?
      Thanks for the help.

      EDIT 1:

      Following the answer the subscription should be like this: Right?

      curl --include \
      --header 'Content-Type: application/json' \
      --request POST \
      --data-binary '{
      "description": "Day subscription",
      "subject": {
      "entities": [

      { "idPattern": "es-leon-.*", "type": "Event" }

      ],
      "condition": {
      "attributes": [
      "Title",
      "dFlag"
      ],
      "expression":

      { "q": "dFlag > 0" }

      }
      },
      "notification": {
      "http":

      { "url" : "http://localhost:5050/notify" }

      ,
      "attributes": [
      "Title",
      "dFlag"
      ],
      "attrsFormat":"legacy"
      }
      }' \
      'http://localhost:1026/v2/subscriptions'

      But I'm still getting an error:

      HTTP/1.1 100 Continue

      HTTP/1.1 400 Bad Request
      Connection: Keep-Alive
      Content-Length: 67
      Content-Type: application/json
      Fiware-Correlator: 60a0a1d2-1ddf-11e6-8bd6-000d3a23bf27
      Date: Thu, 19 May 2016 16:33:11 GMT

      {"error":"BadRequest","description":"no condition attrs specified"}

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 15:14|CREATED monitor | # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 15:14|CREATED monitor | # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 18:10|UPDATED status: transition Answer| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 18:10|UPDATED status: transition Answer| # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 21:10|UPDATED status: transition Finish| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 21:10|UPDATED status: transition Finish| # answers= 1, accepted answer= True

          People

          • Assignee:
            backlogmanager Backlog Manager
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: