- Introduction
- How it works
- API Endpoints
- Implementation
- Features and App details
- Deploying the App
- DevOps Strategy
- References
This project is built to demonstrate how to develop Asset Management Microservice application using Microprofile. This application provides asset CRUD operations from a NoSQL database Cassandra.
- Based on MicroProfile.
- Persist asset data to Cassandra.
- Deployment options for local environment and ICP.
The Asset Management Microservice serves 'IBM Cloud Native Reference Architecture' suite, available at https://github.com/ibm-cloud-architecture/refarch-asset-analytics. Though it is a part of a bigger application, the Asset Management service is itself an application that persists the data of assets to Cassandra database.
POST /assetmanager/assets
Asset object must be passed as JSON object in the request body with the following format:
{
"id":"1",
"os":"testdata",
"version":"testdata",
"type":"testdata",
"ipAddress":"testdata",
"antivirus":"testdata",
"rotation":1,
"current":1,
"pressure":1,
"flowRate":1,
"temperature":1,
"riskRating":-1,
"latitude":"testdata",
"longitude":"testdata",
"creationDate":"2018-11-09T17:02:37-06"
}On success, the below is returned.
{
"id":"1",
"os":"testdata",
"version":"testdata",
"type":"testdata",
"ipAddress":"testdata",
"antivirus":"testdata",
"rotation":1,
"current":1,
"pressure":1,
"flowRate":1,
"temperature":1,
"riskRating":-1,
"latitude":"testdata",
"longitude":"testdata",
"creationDate":1541804557000
}POST /assetmanager/events
AssetEvent object must be passed as JSON object in the request body with the following format:
{
"id":"1",
"current": 1,
"rotation": 1,
"pressure": 28,
"temperature": 28
}On success, the below is returned.
{
"id": "1",
"rotation": 1,
"current": 1,
"pressure": 28,
"temperature": 28
}GET /assetmanager/assets
On success, returns all the assets in the data store.
GET /assetmanager/assets/{id}
On success, Returns all assets available in the datastore based on Id.
GET /assetmanager/assets/type/{type}
On success, Returns all assets available in the datastore based on Type.
GET /assetmanager/events
On success, returns all the asset events in the data store.
GET assetmanager/events/{fromDate}/{toDate}
For eg. assetmanager/events/2018-07-19 12:10:12 /2018-10-02 22:23:20
On success, returns all the asset events between the dates you mentioned.
PUT /assetmanager/assets/{id}
Asset object must be passed as JSON object in the request body with the following format:
{
"id":"1",
"os":"updtestdata",
"type":"updtestdata",
"ipAddress": "0.0.0.0",
"version": "1.0.0",
"antivirus":"updtestdata"
}On success, Asset with ID 1 got updated is returned.
DELETE /assetmanager/assets/{id}
On success, Asset with ID 1 got deleted is returned.
MicroProfile is an open platform that optimizes the Enterprise Java for microservices architecture. In this application, we use MicroProfile 1.3.
You can make use of this feature by including this dependency in Maven.
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>1.3</version>
<type>pom</type>
<scope>provided</scope>
</dependency>You should also include a feature in server.xml.
<server description="Sample Liberty server">
<featureManager>
<feature>microprofile-1.3</feature>
</featureManager>
<httpEndpoint httpPort="${default.http.port}" httpsPort="${default.https.port}"
id="defaultHttpEndpoint" host="*" />
</server>-
Java SE 8 - Used Java Programming language
-
CDI 1.2 - Used CDI for typesafe dependency injection
-
JAX-RS 2.0.1 - JAX-RS is used for providing both standard client and server APIs for RESTful communication by the MicroProfile applications.
-
Eclipse MicroProfile Config - Configuration data comes from different sources like system properties, system environment variables, *.properties etc. These values may change dynamically. This feature enables us to pick up configured values immediately after they got changed.
The config values are sorted according to their ordinal. We can override the less important values from outside. The config sources three locations by default, and the list below shows their rank in priority from most to least:
-
System.getProperties()
-
System.getenv()
-
all META-INF/microprofile-config.properties files on the ClassPath.
In our sample application, we obtained the configuration programmatically.
You can deploy the application locally on your system or on IBM Cloud Private based on your convenience.
To deploy it on IBM Cloud Private, please follow the instructions provided here.
To deploy it on Docker Edge, please follow the instructions provided here.
To deploy the app locally and test the individual service, please follow the instructions provided here.
You can use Microclimate as your end-to-end development environment. It helps us from coding the application locally to deploying the application using a pipeline.
Using this, you can
- Have a simple containerized dev environment
- Load test your application with JMeter
- Templates are in built
- Built in logging
- Easy deployments
- End-to-end environment from development to deployment.
To integrate the app with Microclimate on IBM Cloud Private, please follow the instructions here.
