Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

templates-ehcache

Summary

Template / Example for a microservice using spring cache abstraction and EHCACHE library.

Spring Cache Abstraction: https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/cache.html

EHCACHE: https://www.ehcache.org/

Use case

For device / asset integration the external id (unique external identifier) is used for correlate devices and assets. To keep the communication less frequent to the platform a managed cache can be used. Be aware server side (microserivce) integration has fewer problems with frequent platform communication. This approach is more interesting for agent and edge development, where bandwidth to cloud isn't always high.

This example shows how external IDs (Identity) and managed objects (Inventory) get cached using ehcache. Also a inventory listener is implemented. If the microservice gets notified that managed object has changed, managed object will be removed (evict) from cache. There are also many configuration possibilities for ehcache, see ehcache.xml. For example expiry and heap.

How to run locally:

  1. Build project

mvn clean install

  1. Create application at cumulocity

POST 'https://{base-url}/application/applications'

Request body:

{
  "key": "templates-ehcache",
  "name": "templates-ehcache",
  "contextPath": "templates-ehcache",
  "type": "MICROSERVICE",
  "manifest":{},	
	"requiredRoles": [
		"ROLE_INVENTORY_READ",
		"ROLE_INVENTORY_CREATE",
		"ROLE_INVENTORY_ADMIN",
		"ROLE_IDENTITY_READ",
		"ROLE_IDENTITY_ADMIN"
	],
	"roles": [
	]
}
  1. Subscribe application to your tenant via UI

  2. Acquire microservice bootstrap credentials

GET 'https://{base-url}/application/applications/{applicationId}/bootstrapUser

Response body:

{
    "password": "************************",
    "name": "servicebootstrap_templates-ehcache",
    "tenant": "<your tenant>"
}
  1. Add bootstrap credentials

to your src/main/resources/application-dev.properties

  1. Start microservice with spring profile "dev"

java -Dspring.profiles.active=dev -jar cumulocity-microservice-templates-ehcache-0.0.1-SNAPSHOT.jar

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.