Microservice architecture is a popular approach for building cloud-native applications in which each capability is developed as an independent service. It enables small, autonomous teams to develop, deploy, and scale their respective services independently.
MicroProfile is a modular set of technologies that are designed so that you can write cloud-native Java™ microservices. In this introduction, learn how MicroProfile helps you develop and manage cloud-native microservices. Then, follow the Open Liberty MicroProfile guides to gain hands-on experience with MicroProfile so that you can build microservices with Open Liberty.
Rapidly deploy cloud-native Java microservices at scale
Cloud-native is an industry-wide approach to developing and rapidly deploying applications to the cloud at scale. Cloud-native applications are designed around team-aligned microservices and developed by using agile practices and continuous integration/continuous delivery (CI/CD) to streamline deployment. With a range of vendors that provide cloud platforms, open source and open standards are essential enablers for avoiding vendor lock-in.
MicroProfile enables you to develop and deploy cloud-native Java applications as loosely coupled, lightweight services, each representing one unique business function. This approach is modular and makes the application easy to understand, easy to develop, easy to test, and easy to maintain. If you need even more capability in your application, you can add Java EE features too. Add Java EE 8 features if you are using MicroProfile 2.0 or later on Open Liberty, or add Java EE 7 features if you are using MicroProfile 1.x on Open Liberty.
MicroProfile 5.0 aligns with Jakarta EE 9.1. With this release, applications can use MicroProfile APIs together with Jakarta EE 9.1 APIs. MicroProfile 5.0 has the same functions as MicroProfile 4.1 except for dependency updates that account for changes in Jakarta API package names from
MicroProfile 6.0 aligns with Jakarta EE 10. It includes Jakarta EE 10 Core Profile and replaces MicroProfile OpenTracing with MicroProfile Telemetry. Therefore, MicroProfile OpenTracing moves out of the umbrella release and becomes a stand-alone specification. For more information about Jakarta EE 10 Core Profile, see the Core Profile specification.
Production benefits of a Microservice architecture
Writing code more quickly isn’t the only reason that MicroProfile is popular. It also helps your applications scale on a more granular level because each service is built and managed independently. The high-traffic services can be individually scaled to efficiently use resources rather than scaling up the entire system. Another benefit is that failures in one service can be isolated from the rest of the system. If a service fails, services that are independent are unaffected while dependent services can employ fault tolerance strategies to prevent the failure from cascading to other services.
Although a microservice architecture provides many benefits, it also introduces new challenges not apparent in traditional monolithic applications. MicroProfile addresses these challenges so that you can easily develop cloud-native applications. These challenges include toleration of service failures, end-to-end security for an authenticated user request that flows through a set of microservices, and problem determination for requests that span many services.
MicroProfile simplifies developing cloud-native Java microservices
Most cloud-native microservices are based on REST APIs, making the bottom layer the most essential. At its foundation, MicroProfile provides a set of technologies that make developing and using REST APIs easy. MicroProfile takes a small set of Java EE APIs — JAX-RS, CDI, JSON-B, and JSON-P — and augments them with a simple type-safe REST client API, making it easy to consume REST services. MicroProfile Reactive Streams Operators is the enabling technology for MicroProfile reactive programming for microservices. This feature enables creation and manipulation of reactive streams by bundling a Reactive Streams API together with a set of standard operators that apply to streams.
Build REST services
The JAX-RS, CDI, JSON-B, and JSON-P Java EE technologies provide the base for MicroProfile. If you’re new to Java EE and MicroProfile, this is a good place to start. JAX-RS is a Java API that allows you to build REST APIs by creating resource classes and adding appropriate annotations to create the necessary web endpoints. Context and Dependency Injection (CDI) provides objects with the dependencies that they need through the
@Inject annotation rather than directly creating an object or finding them using a factory. JSON-P and JSON-B make it easy to automatically serialize and deserialize classes to and from JSON.
Try it now: Learn how to create a REST service with JAX-RS, JSON-P, and Open Liberty in our guide to Creating a RESTful web service.
Consume a REST service with type-safe Java
MicroProfile Rest Client provides a type-safe approach for invoking REST services over HTTP. This API greatly simplifies the client-side API as defined by JAX-RS. MicroProfile Rest Client handles the communication between the client and service. You only need to define and annotate an interface that describes the actions that you need to perform on a REST resource. An implementation of this interface is automatically generated for you when CDI is used to inject your client into a dependent class.
Try it now: Learn how to use MicroProfile Rest Client to invoke RESTful microservices over HTTP in a type-safe way in our guide to Consuming RESTful services with template interfaces.
For more information, see REST clients.
MicroProfile simplifies scaling your organization
Handling hundreds of autonomous, collaborating, and frequently evolving services introduces a number of new challenges. These challenges include, for example, documenting and sharing APIs across teams, propagating security across services, handling network or service failures, and continuously integrating and deploying service updates. The middle layer of MicroProfile features provides a number of APIs to simplify these tasks.
Document your REST APIs
MicroProfile OpenAPI provides a Java API for the OpenAPI specification that you can use to expose API documentation for your REST APIs. You can natively produce OpenAPI documents from your JAX-RS applications. OpenAPI is a standardization of the Swagger specification.
Try it now: Explore how to document and filter RESTful APIs by using MicroProfile OpenAPI in our guide to Documenting RESTful APIs.
For more information, see API documentation with OpenAPI.
Handle unexpected failures in your microservices
MicroProfile Fault Tolerance provides an API and annotations for building robust behavior to cope with unexpected failures in the service you depend on. Aspects of fault tolerance include timeouts, retries, fallbacks, bulkhead processing, and circuit breakers.
Try it now: Explore how to manage the impact of failures by using MicroProfile Fault Tolerance in the following guides that are written by our team:
For more information, see Fault tolerance in microservices.
Manage authentication and role-based access control
MicroProfile JSON Web Token (JWT) provides for interoperable authentication and role-based access control for your services. It allows an authenticated JWT token to be shared across multiple microservices even if these services are running on multiple vendor implementations. It also allows access to microservice operations to be controlled based on user and role information that is passed within the JWT token.
Try it now: Explore how to control user and role access to microservices with MicroProfile JWT in our guide to Securing microservices with JSON Web Tokens.
For more information, see Single sign on: JSON Web Token.
Externalize configuration to improve portability
MicroProfile Config externalizes configuration from the application to improve portability of the application. A core principle is to be able to override configuration at deployment time by using system properties and environment variables. This capability means you can build your microservice once and deploy it many times through your CI/CD pipeline by changing the configuration for each deployment.
Try it now: Learn how to configure microservices using MicroProfile Config in these guides, written by our team:
For more information, see External configuration of microservices.
MicroProfile helps you write observable microservices
Handling hundreds of microservices requires a strong operations focus. If the system is beginning to exhibit problems, how do you track down the root cause when a request might span tens or hundreds of services? How can you tell which service is not performing well, or understand the journey that a request took through those microservices? The top layer of the MicroProfile feature set helps you answer these questions. It provides APIs to help you understand the health of services, how they’re performing, and how requests are flowing through them.
Determine a microservice’s availability
MicroProfile Health Check provides a common REST endpoint format to determine whether a microservice is healthy or not. Health can be determined by the service itself and might be based on the availability of necessary resources (for example, a database) and services. The service itself might be running but considered unhealthly if the things it requires for normal operation are unavailable. The Health Check endpoints are also designed to be easily integrated into Kubernetes liveness and readiness probes.
Try it now: Explore how to report and check the health of a microservice with MicroProfile Health in these guides, written by our team:
For more information, see Health checks for microservices.
Monitor a microservice’s telemetry data
MicroProfile Metrics provides common REST endpoints for monitoring the telemetry data of a running microservice, similar in nature to JMX, but a much simpler API that uses JAX-RS. Both built-in and application-defined metrics are accessible, with the output in either JSON or Prometheus text formats. This API provides more extensive detail than the simple up and down reporting provided by MicroProfile Health.
Try it now: Explore how to provide system and application metrics from a microservice with MicroProfile Metrics in our guide to Providing metrics from a microservice.
For more information, see Microservice observability with metrics.
Enable distributed tracing of your microservices
MicroProfile Telemetry is based on the OpenTelemetry project, which is a collection of open source vendor-agnostic tools, APIs, and SDKs for creating and managing trace data.
In Open Liberty, MicroPRofile Telemetry is supported by the MicroProfile Telemetry feature. You can export the data that this feature collects to tracing systems such as Jaeger or Zipkin. For more information, see Enable distributed tracing with MicroProfile Telemetry.
MicroProfile Telemetry replaces MicroProfile OpenTracing. For information about migrating your applications from MicroProfile OpenTracing to MicroProfile Telemetry, see Differences between MicroProfile Telemetry 1.0 and MicroProfile OpenTracing 3.0.
Other MicroProfile features
In addition to the three layers of MicroProfile features that comprise the MicroProfile stack, these additional MicroProfile features are implemented in the Open Liberty runtime but are not yet part of an official MicroProfile release. These features extend the MicroProfile core capabilities, giving you enhanced control over concurrency and reactive programming in your microservice-based applications.
Manage concurrent tasks in your microservices
Concurrency, or the ability to coordinate and track multiple tasks at once, is a key capability in microservice-based applications. MicroProfile Context Propagation enhances Java SE and Java EE concurrency support by providing context awareness between concurrent tasks, which improves consistency and visibility across an application. With MicroProfile Context Propagation, your applications react to events as they happen, under a dependable thread context, and backed by the performance of Liberty threading.
Try it now: Explore how to obtain consistent, reliable thread contexts with MicroProfile Context Propagation in our overview of Concurrency with MicroProfile Context Propagation.
Try it now: Learn how to implement pipelines that manage flow-control and error handling in this blog post on Reactive programming in microservices.
For more information, see Concurrency in microservices.
Send and receive messages between microservices
MicroProfile Reactive Messaging provides an easy way to send, receive, and process messages between microservices in an application. It also provides a Connector API that enables your methods to be connected to external messaging systems. With MicroProfile Reactive Messaging, Liberty converts your annotated application bean methods to reactive streams-compatible publishers, subscribers, and processors, and connects them to each other.
Try it now: Explore how to enable messaging between your microservices and with external systems in our blog post on Sending and receiving messages between microservices with MicroProfile Reactive Messaging
Implement reactive programming for microservices
MicroProfile Reactive Streams Operators provides a way to implement publish/subscribe pipelines that provide flow control and elegant error handling for asynchronous data streams. This implementation enables the processing of streams of data without publishers overwhelming downstream subscribers. Reactive Streams Operators can increase efficiency under potentially overloading conditions by using a ticketing system that creates 'back pressure' between the publisher and subscriber. Because you can directly connect publishers and subscribers regardless of underlying technology, Reactive Streams Operators serves as an abstraction that can efficiently bind together different technologies.