Code Monkey home page Code Monkey logo

softwareag / cumulocity-microservice-templates Goto Github PK

View Code? Open in Web Editor NEW
10.0 6.0 4.0 390 KB

Collection of templates / examples to give the developer a starting point how common features can be solved by using Cumulocity Microservice SDK for Java. Developed by Global Competency Center IoT

License: Apache License 2.0

Java 96.10% Dockerfile 3.90%
cumulocity c8y microservice-sdk samples ehcache microservice spring-boot cumulocity-iot iot-analytics cumulocity-example

cumulocity-microservice-templates's Introduction

cumulocity-microservice-templates

Summary

Collection of templates / examples to give the developer a starting point how common features can be implemented in a Microservice by using Cumulocity's Microservice SDK for Java.

Templates & Examples

  • basic

    • how to communicate with Cumulocity's REST API
    • how to implement REST endpoints, e.g. GET or POST
    • how to implement a scheduler
    • how to work with different contexts
  • agent

    • how to create an agent representation for your Microservice
    • how to subscribe and receive configuration updates for your Microservice
    • how to write events
    • how to create measurement for microservice diagnostic (total, used and free memory)
  • realtime

    • how to subscribe and listen for realtime notifications
    • how to get notified once a managedObject is being updated
    • how to get notified once a new measurement has been created for a device
    • how to receive operations and update their status
  • secret

    • how to use tenant options
    • how to encrypt data and store it as a tenant option
  • ehcache

    • how to use ehcache to implement a caching mechanism for External Ids and managedObjects
  • multischeduler

    • how to start a separate scheduler thread for each tenant to run tasks in parallel.
  • metrics

    • how to use the Micrometer Framework with custom metrics to enable fine grainular monitoring of a microservice and its custom business logic.
  • interprocess communication - IPC

    • how to implement a interprocess communication between microservices based on REST. The solution is using a declarative REST client (Feign Spring Cloud) to call another microservice.
  • context

    • how to use user & tenant context in microservices.

Disclaimer

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.

Contact

For more information you can Ask a Question in the TECHcommunity Forums.

You can find additional information in the Software AG TECHcommunity.


Contact us at TECHcommunity if you have any questions.

cumulocity-microservice-templates's People

Contributors

cguether avatar haraldmeyer avatar ksbn7 avatar mvoigt-sag avatar pestusatsag avatar switschel avatar techcommunity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cumulocity-microservice-templates's Issues

Building of cumulocity-microservice-templates-metrics fails

looks like a dependency is missing:

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/MeasurementService.java:[5,31] package org.apache.commons.lang does not exist [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/MeasurementService.java:[14,38] package com.cumulocity.rest.pagination does not exist [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/DeviceService.java:[6,31] package org.apache.commons.lang does not exist [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/DeviceService.java:[16,38] package com.cumulocity.rest.pagination does not exist [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/MeasurementService.java:[47,21] cannot find symbol symbol: variable StringUtils location: class com.c8y.ms.templates.metrics.service.MeasurementService [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/MeasurementService.java:[58,46] cannot find symbol symbol: variable RestPageRequest location: class com.c8y.ms.templates.metrics.service.MeasurementService [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/DeviceService.java:[75,132] cannot find symbol symbol: variable RestPageRequest location: class com.c8y.ms.templates.metrics.service.DeviceService [ERROR] /mnt/c/Users/hame/git/cumulocity-microservice-templates/metrics/src/main/java/com/c8y/ms/templates/metrics/service/DeviceService.java:[91,21] cannot find symbol symbol: variable StringUtils location: class com.c8y.ms.templates.metrics.service.DeviceService

Change log level dynamically not working

I'm trying out the basic example, specifically the functionality to change the log level dynamically as described here: https://github.com/SoftwareAG/cumulocity-microservice-templates/tree/main/basic#changing-the-log-level-dynamically

However, this does not seem to work. Steps I've did:

  1. Clone repository on main branch
  2. do mvn clean install
  3. create the application in my tenant & subscribe
  4. get bootstrap credentials and add them to application-dev.properties
  5. making sure there's management.endpoints.web.exposure.include=health, loggers line in application-dev.properties
  6. Run build: java -Dspring.profiles.active=dev -jar cumulocity-microservice-templates-basic-0.0.1-SNAPSHOT.jar

Service runs fine on my localhost, a curl http://localhost:8080/health returns up. However, none of these calls returning logger info:

  • curl http://localhost:8080/loggers
  • curl http://localhost:8080/loggers/com.c8y.ms.templates.basic.service
  • curl http://localhost:8080/actuator/loggers

Am I missing something here? Is it working on your side?

running microservice on cloud stop recieving measurement

I have used onNotification() Measurement subscription to listen for measurement .its working fine in local but when i deploy this microservice n cloud c8y its working for few hour and stop receiving measurement after that.

here is the Microservice error logs.

An error occurred for the measurement subscription

com.cumulocity.sdk.client.notification.ReconnectedSDKException: bayeux client reconnected clientId: 12esrya280bwq6n96g1nqc4keq3
at com.cumulocity.sdk.client.notification.SubscriberImpl.resubscribeAll(SubscriberImpl.java:192)
at com.cumulocity.sdk.client.notification.SubscriberImpl.access$900(SubscriberImpl.java:39)
at com.cumulocity.sdk.client.notification.SubscriberImpl$ReconnectOnSuccessfulConnected.rcvMeta(SubscriberImpl.java:273)
at org.cometd.common.AbstractClientSession.extendRcv(AbstractClientSession.java:99)
at org.cometd.common.AbstractClientSession.receive(AbstractClientSession.java:221)
at org.cometd.client.BayeuxClient$7.postCreate(BayeuxClient.java:630)
at org.cometd.client.BayeuxClient.changeState(BayeuxClient.java:971)
at org.cometd.client.BayeuxClient.processHandshake(BayeuxClient.java:613)
at org.cometd.client.BayeuxClient$HandshakeTransportListener.processMessage(BayeuxClient.java:1088)
at org.cometd.client.BayeuxClient$PublishTransportListener.onMessages(BayeuxClient.java:1066)
at com.cumulocity.sdk.client.notification.MessageExchange$ResponseConsumer.handleContent(MessageExchange.java:266)
at com.cumulocity.sdk.client.notification.MessageExchange$ResponseConsumer.getMessagesFromResponse(MessageExchange.java:209)
at com.cumulocity.sdk.client.notification.MessageExchange$ResponseConsumer.run(MessageExchange.java:156)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
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)

Build fails

Trying to build the root mvn module fails with the following message:
class lombok.javac.apt.LombokProcessor (in unnamed module @0x3ea8ff31) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x3ea8ff31

APPLICATION FAILED TO START

I have build parent pom and import in eclipse.after trying cumulocity-microservice-templates-realtime Project using mvn spring-boot:run i am getting below error


APPLICATION FAILED TO START


Description:

Field platform in com.c8y.ms.templates.realtime.controller.NotificationController required a bean of type 'com.cumulocity.sdk.client.PlatformImpl' that could not be found.

Action:

Bean of this type is no longer available.
Instead inject platform APIs directly or inject com.cumulocity.sdk.client.Platform and get the same platform APIs instances with getters.
Use relative URL's starting with '/' with RestConnector bean to have them resolved automatically against the host defined in PlatformParameters#getHost().

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.