What is Microservice?
Microservice is a software architecture style containing a collection of independent services representing a business function to form a complete system.
Monolithic architecture combines all the business functions into a single application for deployment as a single unit. Microservice architecture takes individual business functions, packages them into their own services, and then deploys and scales them independently.
What is Microprofile?
Microprofile is a project that defines a programming model (CDI-centric) and a platform that optimizes Java Enterprise for microservices.
Eclipse released Microprofile as an open-source product with version 1.0 in 2016 with CDI, JAX-RS, and JSON-P. Currently, at version 3.0 since June 2019, it provides application portability across various runtimes.
Motivations for Microprofile
Without many releases, there was a slowdown in Java EE innovation, which led to negative perceptions of its technology. Simultaneously, web services continued to evolve, leading to the creation of new technologies such as JSON, HTTP2, RESTFul web services, and microservices architecture.
This space is utilized by the vendors to provide their own ways on the right approach to do microservices. To overcome stagnation, there was cohesion formed among vendors and user groups to make the microservices better.
As the Java EE profile is extensive with a vast number of APIs, it seems faulty to include all of them when building microservices, i.e., something as “micro,” especially when the majority of them are not used. A set of standards is required to offer guidance to every developer building a microservice, and they need to evolve at a fast pace to adjust to the microservices world.
Payara, Fujitsu, IBM, RED Hat, Oracle, Hammock, and Tomitribe
Functional Components of Microprofile
Configuration: Applications need to be configured based on the running environment without repacking the application. This allows externalizing the configuration to increase the portability of the application.
Fault tolerance: Helps the API and annotations handle unexpected failures of specific microservices.
- It proposes to focus on the following aspects:
- Timeout: Define duration for a timeout of the service.
- Retry policy: A policy to define criteria on when to retry.
- Fallback: Provides an alternative solution in case of any failure.
- Bulkhead processing: Isolate all the failures in part of the system while the rest can still work.
- Circuit breakers: To prevent the repeated timeouts, define a way/rule to achieve fail-fast by automatically failing execution to avoid overloading of the system, indefinite waiting, or timeout by clients.
- JWT Propagation: MP-JWT provides interoperable authentication and role-based access control. It allows an authenticated JWT token to be shared across multiple microservices irrespective of their vendor implementation.
- Health Check: MP-Health is used to probe the state of a node from another machine to determine its liveliness. It signals its state to other machines (i.e., Kubernetes service controller). It’s targeted for cloud-based environments where automated processes maintain the states of the nodes. Health checks are used to determine if a node needs to be terminated or shut down and replaced with a new healthy node. It is not a monitoring solution for human operators.
- Metrics: Provide common REST endpoints to monitor telemetry data and aim to provide a way to export it to management agents.
- Open Tracing: Allows services to participate in a distributed tracing environment. It defines behaviors and the API for accessing an OpenTracing-compliant tracer object within the microservice. These logs can be consumed by a third-party distributed tracing facility.
- Open API: Provides a JAVA API that developers can use to expose their API documentation.
- Rest Client: MP-RestClient provides a typesafe approach to invoke RESTful services over HTTP. It uses JAX-RS2.0 API for reuse and consistency.
For more information on Microprofile, APIs, or SOA, feel free to reach out to us via the comment section below or contact us here.