layout | title | date | categories | author_picture | author_github | seo-title | seo-description | blog_description |
---|---|---|---|---|---|---|---|---|
post |
Writing Java microservices with MicroProfile 1.3 |
2018-06-08 11:30:00 +0000 |
blog |
Writing Java microservices with MicroProfile 1.3 - OpenLiberty.io |
Find out how to build Java microservices with MicroProfile 1.3. Get a brief introduction to the technologies and links to guides so you can quickly get started. |
Find out how to build Java microservices with MicroProfile 1.3. Get a quick introduction to microservices, MicroProfile, and an overview of each of the MicroProfile 1.3 technologies, including Config, Metrics, Health Check, JWT, OpenAPI, OpenTracing... Each summary gives links to relevant guides so you can find out more and try out the technologies with your own bare hands. |
Eclipse MicroProfile is a set of vendor-neutral Java extensions for building fault-tolerant, scalable Java microservices. With MicroProfile on Open Liberty, you can build and deploy applications as loosely-coupled services, each representing one unique business function.
A microservices architecture is a collection of loosely-coupled services, each representing one unique business function in your application. This approach is more modular and makes the application easy to understand, easy to develop, and easy to test. It also enables small, autonomous teams to develop, deploy, and scale their respective services independently.
A monolithic architecture (left) packages all aspects of the business functionality into a single application. All services are interdependent and deployed as a single unit.
A microservice architecture (right) packages each business function separately as its own service. Each service is independent and developed, tested, and deployed independently.
MicroProfile is a vendor-neutral programming model which is designed in the open for developing Java microservices. It provides the core capabilities you need to build fault-tolerant, scalable microservices.
Because MicroProfile is developed in the open and is a collaboration between several partners, it means we can be innovative and fast! MicroProfile is part of the Eclipse Foundation.
The project has released three updates to MicroProfile in 2017 and are working on more for 2018. Open Liberty is implementing these updates as fast as they are being agreed. The most recent release of Open Liberty, 18.0.0.1, contains a full implementation of MicroProfile 1.3.
MicroProfile 1.3 is our latest release and contains the following capabilities:
-
Externalize configuration to improve portability (Config 1.2)
-
Handle unexpected failures in your microservices (Fault Tolerance 1.0)
-
Authentication and role-based access control (JWT Propagation 1.0)
-
Enable distributed tracing of your microservices (OpenTracing 1.0)
-
Consuming a RESTful web service with type-safe Java (Rest Client 1.0)
The Config 1.2 component externalizes configuration from the application to improve portability of the application. A core principal is to be able to override configuration at deployment time using system properties and environment variables. Config 1.0 was the key component for the first Eclipse MicroProfile 1.1 release, and has had two iterations since.
The Config technology is also being proposed as the Configuration API 1.0 JSR through the JCP process.
Find out more:
The Metrics 1.1 component provides common REST endpoints for monitoring a microservice’s telemetry data. Similar in nature to JMX but a much simpler API using JAX-RS. Both built-in and application-defined metrics are accessible, with the output in either Json or Prometheus text formats. Again, this is a popular feature with one update on the books and more to come. This API provides more extensive detail than the simple up/down reporting provided by the Health Check component.
Find out more:
The Fault Tolerance component provides an API and annotations for building robust behavior to cope with unexpected failures in your microservice. Aspects of fault-tolerant execution include timeouts, retries, fallbacks, bulkhead processing, and circuit breakers. This is proving to be one of our most popular features of MicroProfile, and is frequently referenced in conference sessions.
Find out more:
The Health Check component provides a common REST endpoint format to determine microservice availability. This is a simple check to determine if a microservice is alive or not. Contrast with Metrics, which provides much more detail on the running microservice.
Find out more:
The JWT Propagation component provides for interoperable authentication and role-based access control in Java. This MicroProfile feature allows for an authenticated JWT token to be shared across multiple microservices—even if these services are running on other vendors’ implementations. This was one of the first ideas proposed for MicroProfile and we delivered it as part of MicroProfile 1.2.
Find out more:
The OpenAPI component provides a Java API for the OpenAPI v3 specification that you can use to expose their API documentation. You can natively produce OpenAPI v3 documents from their JAX-RS applications. FYI, the OpenAPI specification started off as the Swagger specification.
Find out more:
The OpenTracing component allows services to easily participate in a distributed tracing environment. The specification defines behaviors and an API for accessing an OpenTracing-compliant Tracer object within your microservice. These trace logs can then be consumed by a third-party distributed tracing facility such as Zipkin or Jaeger.
Find out more:
The Rest Client component provides a type-safe approach for invoking RESTful services over HTTP. This API greatly simplifies the client-side API as defined by JAX-RS. The underlying MicroProfile implementation also handles the communication between the client and service.
Find out more:
These three Java EE technologies (JAX-RS, CDI, and JSON-P) provide the base for MicroProfile and were the designated content for MicroProfile 1.0.
Find out more:
Open Liberty 18.0.0.1 implemented MicroProfile 1.3. Pick a MicroProfile technology that you like the sound of and try its guide to see it in action on Open Liberty. Each of the guides takes from 25 – 50 minutes, depending on your experience level. They are all self-sufficient and you can do them in any order.