Skip to content
Snippets Groups Projects
user avatar
OSPODksr authored
1ce75f23
History
Name Last commit Last update
src
README.md
config.json
pom.xml

DKSR-logo

DKSR Connector Example

Licence Information

This code is published by DKSR Gmbh under the German Free Software License. Please refer to the document in the link for usage, change and distribution information: https://www.hbz-nrw.de/produkte/open-access/lizenzen/dfsl/german-free-software-license

Prerequisites

In order to run the Connector following steps are required

Create a new Connector

POST /UrbanPulseManagement/api/connectors

{
  "description": {
    "name": "DKSRExampleConnector",
    "comment": "An example connector sending random numbers"
  },
  "key": "<SECRET>"
}

Create a new EventType

POST /UrbanPulseManagement/api/eventtypes

{
  "name": "DKSRExampleEventType",
  "description": {
    "SID": "The ID of the Sensor",
    "timestamp": "The date and time the corresponding event was fired",
    "value": "A random double for example purposes"
  },
  "config": {
    "SID": "string",
    "timestamp": "java.util.Date",
    "value": "double"
  }
}

Create a new Sensor

POST /UrbanPulseManagement/api/sensors

{
  "senderid": "<ID of the just created Connector>",
  "categories": [],
  "description": {
    "reference": {}
  },
  "location": {},
  "eventtype": "<ID of the just created EventType>"
}

Run the Example Connector

At first, you will need to configure the Connector in order to run it. Therefor you need to edit the supplied config.json in the root directory.

{
  "receiver": {
    "host": "localhost",
    "port": 40777,      
    "useSsl": true,     
    "trustAll": false    
  },
  "sensorId": "<ID of the just created Sensor>",
  "interval": 15000,
  "credentials": {
    "connectorId": "<ID of the just created Connector>",
    "connectorKey": "<SECRET>"
  }
}

Make sure the receiver is properly configured in order to send events to the Inbound module of your UrbanPulse installation.

Once your connector is configured you can build and run the connector with following command. mvn package exec:java

Include jks file for communicating with the OUP Inbound

Copy the jks file from the package/directory of OUP Core for the HTTPInbound Verticle. This path of the jks file is included as an argument in the pom.xml file.

image

See the events sent by the Connector

To check whether UrbanPulse is receiving and processing incoming events properly, you can create a Statement on our DKSRExampleEventType.

Create a new Statement

POST /UrbanPulseManagement/api/statements

{
  "name": "DKSRExampleEventTypeStatement",
  "query": "SELECT * FROM DKSRExampleEventType"
}

Create an UpdateListener for the Statement

POST /UrbanPulseManagement/api/statements/<STATEMENT-ID>/update-listeners

{
  "target": "wss://localhost:3210/OutboundInterfaces/outbound/DKSRExampleEventTypeStatement"
}

Show real-time events

To actually see the real-time events sent by the connector, go to https://localhost:3210/OutboundInterfaces/outbound/DKSRExampleEventTypeStatement

You should see something like

{"_headers":{"eventType":"DKSRExampleEventType"},"statementName":"DKSRExampleEventTypeStatement","value":0.38377175650459394,"timestamp":"2022-05-27T11:04:37.832+0000","SID":"8044ae80-2f1a-4eaf-b8ea-c91de19ec2cb"}

As per th config.json file, these events&JSON Data sets can be seen coming into the OUP Persistence and Outbound module every 15 seconds

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.