Cumulocity Microservice SDK
The Cumulocity Microservice SDK provides the following components:
- Packaging
- Auto-configure
- Context
- Health Indicator
- Logging
- Internal Cumulocity Platform
- Security
- Subscription
Example for fastest usage of microservice SDK:
Add auto-configure maven dependency to your project.
<dependencies> ... <dependency> <groupId>com.nsn.cumulocity.clients-java</groupId> <artifactId>microservice-autoconfigure</artifactId> <version>{enter_cumulocity-clients-java_version}</version> </dependency> </dependencies>
Afterwards, add @MicroserviceApplication annotation to your application. This enables all the necessary components of microservice SDK except packaging.
Introduction and example for creating the microservice package:
Microservice SDK provides maven plugin to create a deployable zip package of the microservice application.
Prerequisites are to have docker installed and permissions granted to use docker commands with non-root users.
As a first step, add microservice package maven plugin to your project.
<build> <plugins> ... <plugin> <groupId>com.nsn.cumulocity.clients-java</groupId> <artifactId>microservice-package-maven-plugin</artifactId> <version>{enter_cumulocity-clients-java_version}</version> <executions> <execution> <id>package</id> <phase>package</phase> <goals> <goal>package</goal> </goals> <configuration> <name>hello-world</name> <encoding>UTF-8</encoding> <rpmSkip>true</rpmSkip> <containerSkip>false</containerSkip> </configuration> </execution> <execution> <id>microservice-package</id> <phase>package</phase> <goals> <goal>microservice-package</goal> </goals> <configuration> <name>hello-world</name> <image>hello-world</image> <encoding>UTF-8</encoding> <skip>false</skip> </configuration> </execution> </executions> </plugin> </plugins> </build>
Create the manifest file cumulocity.json with the example content in the project directory src/main/microservice/.
{ "apiVersion":"1", "version":"@project.version@", "provider": { "name":"..." }, "isolation":"MULTI_TENANT", "requiredRoles": [ ], "roles":[ ] }
Build project and create the microservice zip package using the command:
mvn clean install
The microservice application can be deployed to Cumulocity by uploading the zip package as application to Cumulocity platform.