Giter Club home page Giter Club logo

c8y-adamos-hub-connector's Introduction

!!! Archived -- this repository is currently not actively maintained!

Cumulocity IoT ADAMOS Hub Connector (c8y-adamos-hub-connector)

The Cumulocity IoT ADAMOS Hub Connector provides 2-way synchronization of devices between ADAMOS Hub Services and a Cumulocity IoT Tenant. The following functionality is provided:

  • Synchronization of devices between the ADAMOS Hub MDM Service and the Cumulocity IoT Inventory
  • Mapping of ADAMOS Hub events into Cumulocity IoT Events
  • Mapping of Cumulocity IoT events into ADAMOS Hub Events

The Cumulocity IoT ADAMOS Hub Connector is based on version 1.0 of the ADAMOS Hub Services.

Installation

  • Order the Cumulocity IoT ADAMOS Hub Connector from the ADAMOS Store
  • Fetch the latest release from the Releases page (https://github.com/SoftwareAG/c8y-adamos-hub-connector/releases).
  • Install the microservice (hubconnector-X.Y.Z.zip) on your Cumulocity IoT tenant.
  • Install the UI as an application plugin (ax-ui-hubconnector-microfrontend.zip) into Cumulocity IoT Administration
    • Create Adminstration clone, select Overrule subscribed application to replace the standard Administration application with your clone
    • If you are on Cumulocity IoT 10.13 - 10.15, open the Administration application with ?beta=true appended to the URL
    • Click on your newly created Adminstration clone in the application list. Select Plugins tab.
    • Click on install plugins. Select and install ADAMOS Hub Connector plugin (ax-ui-hubconnector-microfrontend.zip)
    • Open the Administration clone. It might be necessary to clear your browser cache.
  • Create or modify a global role with the Adamos hub Admin / Read / Create / Update permission added. Assign the role to anybody who should be able to access the administration UI.

Settings

Hub Connector Global Settings

  • From the Navigator, expand ADAMOS Hub, and select settings:
    • Synchronization - configures which operations (create, update, delete) should be synchronized in which direction
    • OAuth2 - ADAMOS Hub credentials that the Hub Connector should use. Are provided when order of application from ADAMOS Store is fulfilled.
    • AMQP - ADAMOS Hub credentials to receive events from the ADAMOS Hub. re provided when order of application from ADAMOS Store is fulfilled.
    • Environment - select whether to use the development or production instance of ADAMOS Hub

User Documentation

Device Synchronization

Hub Connector All Devices

The core functionality of ADAMOS Hub Connector is to synchronize devices between ADAMOS Hub and Cumulocity IoT. This is the basis for other functionality like event mappings.

  • The device list by default shows all devices available on the Cumulocity IoT tenant. For each of these devices that are also available on ADAMOS Hub, the status column shows the ADAMOS Hub id. All other devices show a disconnected status. They can be connected using the link button in the rightmost column. This will give the option to link the Cumulocity IoT device to an existing ADAMOS Hub device or to create a new device in ADAMOS Hub. When a device is disconnected from ADAMOS Hub, only the link between the device in Cumulocity IoT and ADAMOS Hub is severed but they are not deleted.
  • When switching the device liszt to ADAMOS Hub devices, all devices in ADAMOS Hub regardless of whether they are available in the Cumulocity IoT tenant are shown. Here it is possible to link ADAMOS Hub devices to new or existing Cumulocity IoT devices and the unlink them again.

Events from Hub

ADAMOS Hub publishes events via AMQP. The ADAMOS Hub Connector can subscribe to these events and map them into Cumulocity IoT measurements, events, and alarms. This mapping is controlled by mapping rules:

Events to Hub

Events produced in Cumulocity IoT can also be sent to ADAMOS Hub to update the state of equipment there. the target events must be events supported by the ADAMOS Hub Event Service (https://enablement.adamos.com/adamos-hub/fuer-entwickler/developer-handbook/event-service/):

  • Name - a human-readable name
  • Cumulocity event type - the type of Cumulocity IoT event to map into an ADAMOS Hub Event
  • Cumulocity devices (optional) - select zero, one, or multiple devices for which this rule should be applied. If no devices are selected, the rule applies for all devices
  • ADAMOS Hub Event Code - the type of the event on ADAMOS Hub (documented here https://enablement.adamos.com/adamos-hub/fuer-entwickler/developer-handbook/introduction/). May include regular expressions.
  • Cumulocity event fragments - one or multiple fragments from the Cumulocity IoT event that should be mapped into the attributes of the ADAMOS Hub Event. No mapping takes place so the fragments should consist of attributeTypeId, value, and state (optional). If a selected fragment points to an array, the array elements will be included individually in the attributes array (the fragment array will be "flattened").

API Documentation

The OpenAPI specification of the Connector API is listed here: https://github.com/SoftwareAG/c8y-adamos-hub-connector/blob/main/hubconnector-oas.json


These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.

c8y-adamos-hub-connector's People

Contributors

haraldmeyer avatar hnaether-sag avatar techcommunity avatar

Stargazers

 avatar

Watchers

 avatar  avatar

c8y-adamos-hub-connector's Issues

Support multi-tenancy hosting

The Hub Connector is currently a single-tenant microservice meaning that it needs to be deployed to each C8Y tenant individually.

Remove CumulocityService

  • instead use Cumulocity client classes directly
  • Replace RESTTemplate calls with Cumulocity client calls or Java standard HttpClient

Provide mapping UI for C8Y -> Hub Events (outbound)

UI currently only supports inbound (Hub Events -> C8Y):
image

There should be another menu entry "Events to Hub" and a page to configure the mapping. At the moment C8Y to ADAMOS Hub event processing is implemented in the Hub Connector Backend in a fixed way:

  • Every 60s all events of type AdamosHubEvent are fetched
  • Check if the device is a Hub-connected device, progress only if true
  • Extract "adamos_hub_data" fragment from C8Y event
  • Enhance extracted fragment with the HUB id of the device and timestamp
  • Send event containing the enriched data to ADAMOS Hub

In the future the mapping should be configurable. A user should be able to select:

  • The Cumulocity event type that should be the source of the mapping (free-text field)
  • Optionally select one or multiple devices for which the event should be mapped. If no device is selected, rule should apply to all devices
  • The ADAMOS Hub event code (=type) as a free-text field
  • A list of fragments from the C8Y event that should be mapped 1:1 into the "attributes" array of the ADMOS Hub event. If the C8Y event fragment is an array, the elements of that array should be flattened into the "attributes" array.

See here for specification of ADAMOS Hub events:
https://enablement.adamos.com/adamos-hub/fuer-entwickler/developer-handbook/event-service/?anchor=Event-definition

The microservice implementation here:

needs to be extended to interpret the mapping rules and start separate listeners per mapping rule. Upon changes of mapping rules, the listeners should be updated. Listener logic should remain polling for the time being (change to Notification 2.0 is treated in #27). Probably best to have one repeated tasks that polls all "listeners".

Event synchronization happens out of order

When multiple events are processed in the same batch, they should be handled oldest first instead they are handled newest first. This might lead to problems with ADAMOS Hub Event Service.

Catch 429 errors in Hub Connector

ADAMOS Hub may return 429 error codes. These are currently not handled properly.

`2022-10-26 05:07:17.533 WARN 13 --- [scheduling-1] c.c.m.context.ContextServiceImpl : execution of task failed within tenant : t51394749 - 429 Too Many Requests: [

<title>429 Too Many Requests</title>

429 Too Many Requests


nginx ] 2022-10-26 05:07:17.533 ERROR 13 --- [scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task

org.springframework.web.client.HttpClientErrorException$TooManyRequests: 429 Too Many Requests: [

<title>429 Too Many Requests</title>

429 Too Many Requests


nginx ] at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:137) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:186) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:125) at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:819) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:777) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:751) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:621) at com.adamos.hubconnector.services.EventRulesService.restToHub(EventRulesService.java:145) at com.adamos.hubconnector.services.EventRulesService.lambda$consumeC8YEvent$0(EventRulesService.java:134) at com.cumulocity.microservice.context.ContextServiceImpl$CallableRunnableWrapper.call(ContextServiceImpl.java:119) at com.cumulocity.microservice.context.ContextServiceImpl$CallableRunnableWrapper.call(ContextServiceImpl.java:109) at com.cumulocity.microservice.context.ContextServiceImpl.callWithinContext(ContextServiceImpl.java:78) at com.cumulocity.microservice.context.ContextServiceImpl.runWithinContext(ContextServiceImpl.java:66) at com.cumulocity.microservice.subscription.service.impl.MicroserviceSubscriptionsServiceImpl.runForEachTenant(MicroserviceSubscriptionsServiceImpl.java:235) at com.adamos.hubconnector.services.EventRulesService.consumeC8YEvent(EventRulesService.java:119) at jdk.internal.reflect.GeneratedMethodAccessor175.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)

`

Create build with translations

With v1015 plugin does not support internationalization. As soon as the new WebSDK version is out which supports that, migrate to that version and create a build with at least German and English translation.

Make dev vs. prod selection of ADAMOS HUB configurable in UI

The Settings page:
image

Should have an additional section to configure the ADAMOS Hub instance. The instance should be selectable from a drop-down list with currently the following values:

  • adamos-hub.dev
  • adamos-hub.com

The selected URL should be part of the HubConnectorGlobalSettings:
https://github.com/SoftwareAG/c8y-adamos-hub-connector/blob/main/ax-mm-hubconnector/src/main/java/com/adamos/hubconnector/model/HubConnectorGlobalSettings.java

The setting should replace the existing app.hubconnector.host setting from the application.properties:
https://github.com/SoftwareAG/c8y-adamos-hub-connector/blob/main/ax-mm-hubconnector/src/main/resources/application.properties

As the other app.hubconnector settings depend on it, the settings in the application.properties should be replaced by a Spring-configured bean. The paths of the individual services do not need to be configurable.

Support 2-way synchronization between C8Y and ADAMOS Hub

At the moment devices can either be imported from the Hub into Cumulocity or exported from Cumulocity into the hub. There are cases where the device might already exist in both systems. Currently one of them would need to be deleted.

The idea is that during import or export the user can either provide a ADAMOS machine ID or the Cumulocity managed object id. ADAMOS Hub is assumed to be the leading system and any existing hub data in Cumulocity would be overwritten.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.